MATLAB: How to write Data at once in an excel sheet (avoid formation of excel sheet in every loop!)

for loopxlswrite

A1 = {'addition','power'};
sheet=1;
xlswrite('prkash',A1,sheet)
for i=1:10
x(i)=1+i;
y(i)=i^2;
k=i+1;
Data = {x(i),y(i)};
xlRange = strcat('A',num2str(k))
xlswrite('prkash',Data,sheet,xlRange)
end

Best Answer

Change
Data{i} = {x(i),y(i)};
To
Data(i, :) = {x(i),y(i)};
That is, you need a 2d cell array not nested cells