Ashwini
Ashwini

Reputation: 11

Appending data to a mat file in MATLAB

I have a mat file with some data and i want to add additional data at the end of file whenever a function is called. How can i do it? By save -append my existing data is overwritten. But for me data should not be overwritten. Reply as early as possible.

Upvotes: 1

Views: 6228

Answers (1)

devrobf
devrobf

Reputation: 7213

You've given no information about the type of data you are storing, but I suspect you might be trying to append values to an array which is stored in a file using -append; however, -append only adds new variables to a file. If you save a variable with the same name, it will overwrite it. Instead, just do the append manually:

I'll assume that we are talking about a 1xn vector, you can adjust the concatenation step as necessary.

x = load('myfile');
x = [ x newX ];
save('myfile', 'x');

Upvotes: 3

Related Questions