Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

i am using a for loop to access each element in a column of an xls file and display the data with the help of GUI.my code is:

Asked by Vishal on 18 Apr 2013

this code is written in the pushbutton callback:

for i=1:4
    a=xlsread('abc.xls',i,'A(i)');
str=sprintf('%d',a);
set(handles.edit1,'string',str);
end

But i am getting an error:

Error using ==> xlsread at 285
Data range is invalid.
Error in ==> sample>pushbutton1_Callback at 82
    a=xlsread('abc.xls',i,'A(i)');

I am new to matlab. Please help.

0 Comments

Vishal

Tags

Products

No products are associated with this question.

2 Answers

Answer by Vishal on 23 Apr 2013
Accepted answer

Iman,i am still getting the same error.

1 Comment

Iman Ansari on 23 Apr 2013

Sorry:

a=xlsread('abc.xls',i,['A' num2str(i)]); 
Vishal
Answer by Iman Ansari on 19 Apr 2013

Hi. Range should be a string:

a=xlsread('abc.xls',i,['A' 'num2str(i)']); 

It's better to read the whole file then use it,

a=xlsread('abc.xls',1,'A1:A4');

0 Comments

Iman Ansari

Contact us