a simple question about for loop

조회 수: 1 (최근 30일)
dediydi
dediydi 2012년 7월 19일
hello all,
i want to use xlswrite function in a for loop ? but i don not know how to name the variable in for
for example ;
for a = (1:10)
xlswrite( 'deneme.xls',writeEx , 1, 'A??')
end
maybe it is simple but very important for my project now. i am looking forwart to hear your answer.
thank you a lot
  댓글 수: 1
Walter Roberson
Walter Roberson 2012년 7월 19일
Why are you writing the same value, "writeEx", multiple times?
Is "writeEx" a scalar or a vector or a matrix? Are you trying to write it across rows or down columns or something else?

댓글을 달려면 로그인하십시오.

답변 (2개)

Nirmal
Nirmal 2012년 7월 19일
편집: Nirmal 2012년 7월 19일
First of all its loop not loob. I hope you meant range as a variable. the following code should work.
for a = (1:10)
b=sprintf('A%i',a)
xlswrite( 'deneme.xls',writeEx , 1, b)
end
  댓글 수: 1
dediydi
dediydi 2012년 7월 19일
it works but not regulary. i want to start to write in excel second row. but when a = (20:50) it starts to write from 20th row. how can i fix it. thank you a lot

댓글을 달려면 로그인하십시오.


Azzi Abdelmalek
Azzi Abdelmalek 2012년 7월 19일
for i=1:10
writeEX=rand(10,10); %exemple of random matrix
xlswrite( 'deneme.xls',writeEX ,['Sht',num2str(i)],'A5')
end
% ['Sht',num2str(i)] are the sheet 1 2 3 ... named sht1 sht2 ...
% 'A5' data start at the fifth line of colon A

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by