比较单元阵列的琴弦检测 [英] comparison of cell arrays of string for piano detect

查看:113
本文介绍了比较单元阵列的琴弦检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用matlab语言进行和弦钢琴检测。我能够识别每一个单音调,我想通过使用字符串比较显示结果,所以我这样的代码

i try make chord piano detection by using matlab language. i able to identify every single tone note and i want to display the result by using string comparison so i make code like this

 function akor=readChord(notes) %notes is input String data type
a1={'A' 'C#/Db' 'E'};
b1={'B' 'D' 'F#/Gb'};
c1={'C' 'E' 'G'};
d1={'D' 'F#/Gb' 'A'};
e1={'E' 'G#/Ab' 'B'};
f1={'F' 'A' 'C'};
g1={'G' 'A#/Bb' 'D'};
%Chord Minor
a2={'A' 'C' 'E'};
b2={'B' 'D' 'F#/Gb'};
c2={'C' 'D#/Eb' 'G'};
d2={'D' 'F' 'A'};
e2={'E' 'G' 'B'};
f2={'F' 'G#/Ab' 'C'};
g2={'G' 'A#/Bb' 'D'};
 a=notes(3,:)
    if v=isempty(setxor(a,a1))==1;
        display('Chord A mayor')
    elseif v = isempty(setxor(a,b1))==1;
        display('Chord B')
    elseif v = isempty(setxor(a,c1))==1;
        display('Chord C mayor')
    elseif v = isempty(setxor(a,d1))==1;
        display('Chord D mayor')
    elseif v = isempty(setxor(a,e1))==1;
        display('Chord E mayor')
    elseif v = isempty(setxor(a,f1)==1;
        display('Chord F mayor')
    elseif v = v = isempty(setxor(a,g1)==1;
        display('Chord G mayor')
    elseif v = isempty(setxor(a,a2))==1;
        display('Chord A minor')
    elseif v = isempty(setxor(a,b2))==1;
        display('Chord B')
    elseif v = isempty(setxor(a,c2))==1;
        display('Chord C minor')
    elseif v = isempty(setxor(a,d2))==1;
        display('Chord D minor')
    elseif v = isempty(setxor(a,e2))==1;
        display('Chord E minor')
    elseif v = isempty(setxor(a,f2)==1;
        display('Chord F minor')
    elseif v = isempty(setxor(a,g2)==1;
        display('Chord G minor')
    else
        display('not Detect')

    end

但它看起来像我有错误
错误:文件:bacagambar.m行:18列:9
等号左边的表达式不是一个有效的目标作业。
任何人都知道我应该做什么

but it look like i have error Error: File: bacagambar.m Line: 18 Column: 9 The expression to the left of the equals sign is not a valid target for an assignment. anyone know what i should did

推荐答案

使用开关

switch note(3,:)
   case {'A' 'C#/Db' 'E'}
      akor = 'Chord A mayor';
   case {'B' 'D' 'F#/Gb'}
      akor = 'Chord B';
   % put all other patters in similar case
   otherwise
      akor = '';
      error('not detected');
end
fprintf( 1, '%s\n', akor );

这篇关于比较单元阵列的琴弦检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆