1
votes

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.

1

1 Answers

3
votes

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');