substituting a column into a 3D matrix
古いコメントを表示
I have a matrix R = zeros(4,5,3) and I want to make the last column of each matrix a different number. such that given C is a vector
for n = 1: end R(:,end, n) = C(n)
I managed a solution where I have a column vector A which if I could substitute into R(:, end, :), but it says mismatch dimensions.
essentially, I want to substitute a column vector into the columns of a 3D matrix R without using a for loop.
1 件のコメント
Jan
2011 年 8 月 21 日
"for n=1:end" is not valid. Better: "for n = 1:size(R, 3)".
採用された回答
その他の回答 (1 件)
Jan
2011 年 8 月 21 日
R = zeros(4,5,3);
A = [1, 2, 3];
R(:, end, :) = reshape(repmat(A, 4, 1), [4, 1, 3]);
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!