Writting multiple arrays to an excel spreadsheet after each loop
7 次查看(过去 30 天)
显示 更早的评论
I am trying to write several arrays into a single excel spreadsheet so that I can manipulate the data and create graphs of it. The arrays are all calculated in a single loop and the data must be written to the excel file each time. It would be convenient if each set of data from each loop was done row by row in excel so I would know which incement the data corresponded to. This is the code
for i=2:hsize+1;
epsglo_top=epsmid+(hh(i-1)*curv)
epsglo_bottom=epsmid+(hh(i)*curv)
epsglo_middle=(epsglo_bottom+epsglo_top)/2
sigmaglo_top=Qbar(:,:,i-1)*epsglo_top
sigmaglo_bottom=Qbar(:,:,i-1)*epsglo_bottom
sigmaglo_middle=(sigmaglo_top+sigmaglo_bottom)/2
m=cos(fibre_radians(i-1));
n=sin(fibre_radians(i-1));
epslocal_top=T*epsglo_top
epslocal_bottom=T*epsglo_bottom
epslocal_middle=(epslocal_top+epslocal_bottom)/2
sigmalocal_top=T*sigmaglo_top
sigmalocal_bottom=T*sigmaglo_bottom
sigmalocal_middle=(sigmalocal_bottom+sigmalocal_top)/2
xlswrite('globalstrain.xls', epsglo_top, 'A1');
xlswrite('globalstrain.xls', epsglo_middle, 'B1');
xlswrite('globalstrain.xls', epsglo_bottom, 'C1');
end
Thanks for the help
0 个评论
回答(2 个)
Tannistha
2012-2-23
Instead of writing each array every single time using xlswrite, why don't you store each set of data in a another matrix and then write the whole matrix at once in excel sheet? it will also save time.
mymatrix=zeros(hsize-1,3)
for k=1:hsize-1
%your code
mymatrix(k,1)=epslocal_top;
mymatrix(k,2)= epslocal_middle;
mymatrix(k,3)=epslocal_bottom);
end
xlswrite('myfile',mymatrix,'mysheet','A1');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Export to MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!