Appending structs in files
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Walter Roberson
el 27 de Jul. de 2015
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.
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!