how to replace a column in a matrix
98 ビュー (過去 30 日間)
古いコメントを表示
I wanna know how to replace a column in below condition:
Assmuing I had a 5*5 matrix, I wanna replace each column by zeros(5,1) for 5 times. I don't mean to get a 5*5 all 0 element matrix eventually. I want to get 5 matrix with their 1st,2nd,3rd,4th,5th column be replaced individually. How could I code for this? Thanks.
2 件のコメント
James Tursa
2019 年 5 月 15 日
What have you done so far? What specific problems are you having with your code? Can you write a loop and put the results into a cell array?
採用された回答
James Tursa
2019 年 5 月 15 日
編集済み: James Tursa
2019 年 5 月 15 日
Instead of replacing all of the columns of A, use a different variable for the result. E.g., a cell array named C. So instead of this:
A(:,i) = B;
you could have this
C{i} = A;
C{i}(:,i) = B;
Then each of C{1}, C{2}, etc contain your matrices
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!