loop inside Index of matrix
1 回表示 (過去 30 日間)
古いコメントを表示
Harel Harel Shattenstein
2015 年 5 月 12 日
回答済み: Walter Roberson
2015 年 5 月 12 日
On the following code
function [d] = matrix( n )
d=zeros(2*n-1);
for i=1:n
d(i:end-i+1,i:end-i)=i;
end
end
How does the following runs?
d(i:end-i+1,i:end-i)=i;
first the rows index increase or the columns? or both at the same time?
0 件のコメント
採用された回答
Walter Roberson
2015 年 5 月 12 日
MATLAB always goes columns first when there is a range. But it doesn't matter when you are assigning a scalar to the block, as all elements of the block are going to be given the same result.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!