For loop to write in Excel file
显示 更早的评论
Hi I have a problem with for loop and xlswrite statements. Actually I want to have a nested loop like this:
fid = fopen ('data1.xlsx', 'r');
fid = fopen ('reg1.txt', 'w');
for i = 1:4
x = data1(:,i);
for j = 2:5
y = data1(:,j);
p = polyfit(x,y,1);
yfit = polyval(p,x);
yresid = y - yfit;
ssresid = sum(yresid.^2);
A = ([i; j; ssresid]);
reg1 = xlswrite('reg.xlsx', [i, j, ssresid]);
end
end
and write the results of all iterations in Excel. However, I don't know how I can do this. The above code can just write the last iteration on the Excel file that it doesn't work for me. I want to have all iterations.
It would be great, If you can help me.
Thanks in advance
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!