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

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

reading excel data, without knowing range

Asked by John on 16 Dec 2011

Hi,

I have a line of code that reads in files from excel for a specific range. However, I don't know the last row of data in every file. Could somebody advise me on how to read in the data without knowing the number of the last row of data in advance.

May thanks

sch_cycle=xlsread('C:\Autonomie drive cycles\NEDC.xlsx','Sheet1','A2:B20');

0 Comments

John

Products

No products are associated with this question.

2 Answers

Answer by Ora Zyto on 16 Dec 2011

John, Does reading from the entire worksheet satisfy your requirements?

B = xlsread('myExample.xls', 'MySheet') 

0 Comments

Ora Zyto
Answer by Aldin on 16 Dec 2011

[~,leng] = xlsread('NEDC.xls','Sheet1', 'A:A'); %column in array

l = length(leng); %length of column

length_string = num2str(l+1);

num = ['A',length_string]; % A1 or A2 or A3 it depends of length

xlswrite('NEDC.xls','Jhon','Sheet1',num);

That's my algorithm :)

0 Comments

Aldin

Contact us