Appending structs in files
1 次查看(过去 30 天)
显示 更早的评论
Depending on the length inputted, with this function I wish to append a new column to one of two structs, nmos and pmos, in an existing file. In this case, I wish to append new values in the nmos struct. The nmos struct contains many variables, such as beff, which in this example is: beff: [100x2 double].
pmos ------> beff, vgs, etc
nmos ------> beff, vgs, etc
This is the code I was using to try an append it to the file:
.
.
.
% if want to append data to existing file
else strcmp(filetype,'append')
save ('filename.mat','nmos','-append');
end
The problem is that each time I use a new length and try to append the new column it erases all the values from the previous columns. For example, nmos.beff becomes:
0 0.0019
0 0.0018
0 0.0018
0 0.0018
0 0.0017
0 0.0017
0 0.0016
0 0.0016
0 0.0016
0 0.0015
when trying to append a second column.
Is there a way to add these new columns without erasing all the previous values?
0 个评论
回答(1 个)
Walter Roberson
2015-7-27
The save -append flag is for adding complete new (named) variables without rewriting the entire file. It is not able to add additional information to an existing variable.
To add information to an existing variable you need to use matlabFile(). Or you need to read the existing value, add to it, and save the variable again.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!