I am running a simulation where i generate huge 2d sparse matrices and hence i use FIND function to only store nonzero values with their indices.
Now for each itera
You can't append data to an existing variable with save
. You need different variables:
clear all
filename = 'data.mat';
save(filename) %// empty file, for now. We'll append variables within the loop
for n = 1:10
A = rand(5);
[i,j,vals] = find(A);
varname = ['data' num2str(n)]; %// varname is 'data1', 'data2' etc
assignin('base',varname,[i,j,vals]); %// create that variable
save(filename, varname, '-append') %// append it to file
end