How do I use a for loop with excel

I am making a for loop that draws in excel and I cannot get the right syntax to change the row given the iteration constant "z". My for loop works when I have for example: 'B5:D5', but when i want to incorporate the iteration constant it does not work. Help please
height = 5
for z = 1:18
if height == z
s= xlsread('myexcelfile','sheet','Bz:Bz')
....the rest of the loop works fine,

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 3월 11일

0 개 추천

height = 5
for z = 1:18
if height == z
s= xlsread('myexcelfile','sheet',sprintf('B%d',z));
end
...
end

댓글 수: 2

carl chew
carl chew 2013년 3월 11일
sorry i meant 'Bz:Dz'
how would i write that?
height = 5
for z = 1:18
if height == z
s= xlsread('myexcelfile','sheet',sprintf('B%d:D%d',z,z));
end
...
end

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

추가 답변 (0개)

카테고리

도움말 센터File 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