필터 지우기
필터 지우기

Using looping and change in xlrange and xlsread

조회 수: 7 (최근 30일)
androidguy
androidguy 2017년 2월 22일
댓글: androidguy 2017년 2월 22일
Hello everyone
I have a tricky question for you. I am having trouble using variables in xlrange while looping. I am trying to change the change the column every iteration by generating the corresponding column alphabet and read the entire column in excel. My code snippet is as follows :
h = 0:5:300;
for k = 1:length(h)
x = 'xlsColNum2Str';
avg_rd = round(xlsread(filename,'sheet1', [x(k) ':' x(k)] ));
% i have some more numerical operations being performed on the column obtained from above variable "avg_rd"
end
The function "xlsColNum2Str" is coming from the below url -
I would appreciate any help in solving this problem.
Thank you,
  댓글 수: 2
androidguy
androidguy 2017년 2월 22일
Just bumping this question to get noticed.
Jan
Jan 2017년 2월 22일
Please do not bump your question. A missing answer is a strong indicator for too few information. Then bumping waste the time of the readers only. Note, that you forgot to mention the problem you want to solve.

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

채택된 답변

Jan
Jan 2017년 2월 22일
편집: Jan 2017년 2월 22일
I guess that you do not want to create the string 'xlsColNum2Str', but to call the function with this name:
h = 0:5:300;
for k = 1:length(h)
range = xlsColNum2Str(k);
avg_rd = round(xlsread(filename, 'sheet1', [range ':' range]));
...
end
It would be faster to import all columns at once with a single xlsread call.
  댓글 수: 1
androidguy
androidguy 2017년 2월 22일
Apologies for bumping my question. But anyway, I took your advise and simply imported my data into a matrix rather than using xlsread every iteration. It's much faster that way. Thanks Jan Simon.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by