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

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by