Writting multiple arrays to an excel spreadsheet after each loop
조회 수: 8 (최근 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에서 Spreadsheets에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!