我尝试通过为我的项目使用字符串数据来进行和弦检测,我制作这样的代码
function akor=NoteAkor(notes)
notes=notes(3,:)
switch notes
case notes={'A','C#/Db','E'}
akor = 'Chord A mayor';
case notes={'B' 'D' 'F#/Gb'}
akor = 'Chord B';
case notes={'C' 'E' 'G'}
akor = 'Chord C mayor'
case notes={'D' 'F#/Gb' 'A'}
akor = 'Chord D mayor'
case notes={'E' 'G#/Ab' 'B'}
akor = 'Chord E mayor'
case notes={'F' 'A' 'C'}
akor = 'Chord F mayor'
case notes={'G' 'A#/Bb' 'D'}
akor = 'Chord G mayor'
case notes={'A' 'C' 'E'}
akor = 'Chord A minor'
case notes={'B' 'D' 'F#/Gb'}
akor = 'Chord B minor'
case notes={'C' 'D#/Eb' 'G'}
akor = 'Chord C minor'
case notes={'D' 'F' 'A'}
akor = 'Chord D minor'
case notes={'E' 'G' 'B'}
akor = 'Chord E mayor'
case notes={'F' 'G#/Ab' 'C'}
akor = 'Chord F mayor'
case notes={'G' 'A#/Bb' 'D'}
akor = 'Chord G mayor'
% put all other patters in similar case
otherwise
akor = '';
error('not detected');
end
fprintf( 1, '%s\n', akor );
但它是错误:文件:NoteAkor.m 行:4 列:14 等号左侧的表达式不是赋值的有效目标。
任何人都可以帮助我修复我的代码,或者给我另一种方法来使这个代码工作?谢谢之前...