Compare arrays in Simulink
13 ビュー (過去 30 日間)
古いコメントを表示
I have two arrays which I would like to compare with each other.
eg. A = [4.1,5.2,7.1] B = [1,2,3,4,5,6,7,8]
I want to be able to say that the following match 4.1->4, 5.2->5, 7.1->7 and then show it in a different array like C = [0,0,0,1,1,1,0]
I have been trying to use For loops but havent managed to solve it as yet. Any suggestions would be useful
*edit
I cannot use a Matlab function block as I need to use it with TargetLink later.
Thanks, Dhruv
5 件のコメント
回答 (2 件)
Azzi Abdelmalek
2013 年 8 月 14 日
A = [4.1,5.2,7.1];
B = [1,2,3,45,6,7,8];
out=zeros(size(B));
out(fix(A))=1
10 件のコメント
Friedrich
2013 年 8 月 14 日
Is a Look-Up-Table supported? If so, this would be what you need together with a For Itterator Subystem.
参考
カテゴリ
Help Center および File Exchange で Simulink Functions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!