could anyone help me how to run the code with respect to different matrices

1 回表示 (過去 30 日間)
jaah navi
jaah navi 2019 年 9 月 21 日
編集済み: Stephen23 2019 年 9 月 21 日
code:
a=max(B)
b=max(a)
for i=1:size(B,1)
bbb= 1:b
bb= B(i,1:2)
bbbb= setdiff(bbb,bb)
BB(i,:)= [bb,bbbb]
end
when i run the code for
B=[1 2;
1 3]
it executes but i want to run the same code with respect to different matrices one by one
B=[1 2]
B=[1 2;
1 3]
B=[1 3;
2 4;
3 4]
B=[1 4;
2 4;
3 4;
1 5;
2 5]
B=[ 1 3;
1 5;
3 5;
4 5;
2 6;
3 6;
4 6;
5 6]
Could anyone please help me on this.
  2 件のコメント
David Hill
David Hill 2019 年 9 月 21 日
Just create a function inputting all the different B inputs, or create a cell array with all the B inputs and use the cellfun function.
Stephen23
Stephen23 2019 年 9 月 21 日
編集済み: Stephen23 2019 年 9 月 21 日
Just put them all into one cell array and then use indexing.
You have been using MATLAB for atleast two years, surely you have learned how to use indexing and cell arrays.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by