How to assign parts of a matrix equal to a single vector
古いコメントを表示
In matlab if you had a vector called y = ones(5,5), you could do the following assignments:
y(:,1) = 0; First column in all rows equals zero.
y(:,1:2) = 0; First two columns in all rows equals zero.
y(1,:) = 0; First row equals zero, etc.
But what if you wanted to be more specific, say for example I had a vector x = [0 2 0] and I wanted y(2:4,2:4) = x; Meaning the middle 3 columns and middle 3 rows would be set to that vector. The problem is it doesn't accept this kind of assignment and gives a "Subscripted assignment dimension mismatch" error. I was wondering if there is any way to do this, or this something like this only possible through a for loop?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Operators and Elementary Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!