MATLAB: Xlswrite

xlswrite

I have a Program where a values of 'A' is changing in each iteration and I want to save each value separately in excel so later I can make a graph, I am using xlswrite but it overwrite the previous value which I don't want them to change , how can I do that ..

Best Answer

Hi Nasir,
Is the value of A a scalar? Even if you could make this work, writing to an Excel file at every loop iteration sounds like slow going. How about preserving the values of A within MATLAB itself:
allA = zeros(numLoopIterations, 1);
for i=1:numLoopIterations
A = ...
allA(i) = A;
end
plot(allA)
I've pre-allocated above for performance reasons, but I suspect even not pre-allocating (if numLoopIternations is not known, for example) will be much faster than writing to Excel:
allA = [];
while ...
A = ...
allA(end+1) = A;
end
plot(allA)