检查单元格是否包含特定值MATLAB

时间:2019-10-15 08:05:32

标签: matlab

是否有更有效的方法来再现这些结果?

store = {'1','2','3','4','5'};

for jj = 1:5
correct(jj) = isequal(store{jj}, '3');
end

这是matlab中的for循环...

1 个答案:

答案 0 :(得分:3)

%%
store = {'1','2','3','4','5'};

for jj = 1:5
correct(jj) = isequal(store{jj}, '3');
end
%%
(strcmp(store,'3'))

strcmp将解决您的问题