How to save and then append/augment a matrix into another already existing matrix?

5 ビュー (過去 30 日間)
Imam
Imam 2014 年 9 月 13 日
回答済み: Imam 2014 年 9 月 13 日
Hi guys, I have got a brief question about saving a file. I have a file named myfile.mat, (meaning this file already exists) and it contains let's say a matrix M of size 20x4 with all-zero elements. Now I want to run a code that produces a matrix N inside a loop of sizes 3x4 where 3 is the number of cycles of that loop. So putting it into a code would look like:
for j = 1:3
.
.
.
.
.
N(j,:) = [a vector of length 4];
end
In the end I will get matrix N of size Cx4. Then I would like to save N into myfile.mat by replacing the elements in M in the rows whose indices match that of the loop indices. So in the above case I would want to fill from 1st to 3rd row of M with the elements of N leaving the other elements in another rows unaffected. Should I set the cycle indices to run from let's say 5 to 10 (j=5:10) then I will fill only elements in row 5 to 10 of M.
Any suggestion for how to do this? Thanks for the help.

採用された回答

per isakson
per isakson 2014 年 9 月 13 日
編集済み: per isakson 2014 年 9 月 13 日

その他の回答 (1 件)

Imam
Imam 2014 年 9 月 13 日
Thanks to you both, that really describes the solution to my problem.

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by