I want to use fonction (find) to return many values,but why he just returns the least value ? thank you

d={ 'a12' ;'a15';'a16';'a14';'a13';'a11'}; H={ 'a11';'a13';'a12' ;'a15';'a16';'a14';'a13'} ; for i=1:1:7 c=find(strcmp(d,H(i)));
end

回答 (1 件)

Julia
Julia 2014 年 10 月 1 日
Hi,
c is overwritten in each loop iteration.
Define c as a matrix and you can store each result in a line of this matrix.

3 件のコメント

pengcheng
pengcheng 2014 年 10 月 1 日
I agree with you,I try to define c as a matrice by many ways,but I don't succeed, can you help me ? Thanks
d={ 'a12' ;'a15';'a16';'a14';'a13';'a11'};
H={ 'a11';'a13';'a12' ;'a15';'a16';'a14';'a13'} ;
c=zeros(7,1);
for i=1:1:7
c(i)=find(strcmp(d,H(i)));
end
c =
6
5
1
2
3
4
5
pengcheng
pengcheng 2014 年 10 月 1 日
thank you very much,you are right,I think I must be confused by (),[],{}

この質問は閉じられています。

タグ

質問済み:

2014 年 10 月 1 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by