配列に数字を代入するプログラムについて
Show older comments
1 1
1 2
1 3
1 4
1 5
2 1
2 2
2 3
2 4
2 5
3 1
3 2
このような2列目が5までいったら、1列目が1ふえるような配列をつくりたいのです。
どのようなプログラムにすればいいですか。
2 Comments
配列の添え字として使うのであれば、ind2sub関数を使う事が出来ます。あっ
x = (1:20)';
[row col] = ind2sub([5 4], x);
disp([col row]); % MATLABのデフォルトは列優先
Toru Ikegami
on 3 Dec 2021
Moved: Atsushi Ueno
on 17 Aug 2022
おー.美しいですね.素晴らしい.
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!