Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Hi, how can i import data from many worksheet in Excel? Can i used a cicle for?please help me

1 回表示 (過去 30 日間)
Giuseppe Zaccaro
Giuseppe Zaccaro 2016 年 7 月 27 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi, how can i import data from many worksheet in Excel? Can i used a cicle for?please help me
  1 件のコメント
Giuseppe Zaccaro
Giuseppe Zaccaro 2016 年 7 月 27 日
I have tried to write: [A]=xlsread('prove.xlsx','15x5_003','A3:A3603'); [B]=xlsread('prove.xlsx','15x5_003','B3:B3603'); plot(A,B)
but i need to do this many time for many worksheets,so I have proved with a for loop,but without success function cnr1 for i=0:5 [A]=xlsread('prove.xlsx','15x5_003+i','A3:A3603'); [B]=xlsread('prove.xlsx','15x5_003+i','B3:B3603'); plot(A,B) end

回答 (1 件)

George
George 2016 年 7 月 27 日
You're trying to use i as your loop index. (Conventionally ii would be used to avoid confusion with i = sqrt(-1) )
However, in your calls to xlsread you're using i as part of the string. e.g.,
[A]=xlsread('prove.xlsx','15x5_003+i','A3:A3603');
treats '15x5_003+i' as char array and it won't interpolate the index variable.
Try
[A]=xlsread('prove.xlsx',['15x5_003+' int2str(i)],'A3:A3603');
which will concatenate the first bit with the string representation of i. (I'd still refactor this to ii.)

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by