Read excel data but keep formatting? Is this possible?

조회 수: 8 (최근 30일)
matlabuser12
matlabuser12 2014년 5월 6일
댓글: matlabuser12 2014년 5월 20일
I have a huge excel data file of data collected every second and the time column is in the format 12:12:56, But when i do an xlsread I do not get the same string. Is there a way to import this properly?

답변 (2개)

Sara
Sara 2014년 5월 6일
Use this form of xlsread, you'll find your variable into txt or raw:
[num,txt,raw] = xlsread(___)
From the help: [num,txt,raw] = xlsread(_) additionally returns the text fields in cell array txt, and the unprocessed data (numbers and text) in cell array raw using any of the input arguments in the previous syntaxes. If xlRange is specified, leading blank rows and columns in the worksheet that precede rows and columns with data are returned in raw.
  댓글 수: 25
Sara
Sara 2014년 5월 8일
Jose meant that you can use activex in matlab. that's a way to do it too, but I have never used it to read from excel, only to write. you may want to look into it anyway.
matlabuser12
matlabuser12 2014년 5월 20일
That's what I would do:
Search for the string time (to know when start reading data)
While reading, check that suddenly there is no empty cell or char
do not stop (as the code does now) but rather keep going until you find "time" again
repeat
I would use a while loop and read a max of 500 lines with no numeric data, so that you have a way to stop the code when you actually reach the end of file. I suppose none would use a header of 500 lines! Take a shot at it, in case you can post again if you go nowhere :) As for the code, it's for you to modify as you please.
I am struggling to do this, where in the code does this go?

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


matlabuser12
matlabuser12 2014년 5월 20일
I am struggling to do this:
That's what I would do:
Search for the string time (to know when start reading data)
While reading, check that suddenly there is no empty cell or char
do not stop (as the code does now) but rather keep going until you find "time" again
repeat
I would use a while loop and read a max of 500 lines with no numeric data, so that you have a way to stop the code when you actually reach the end of file. I suppose none would use a header of 500 lines! Take a shot at it, in case you can post again if you go nowhere :) As for the code, it's for you to modify as you please.
Where in the code does this go?
  댓글 수: 2
Sara
Sara 2014년 5월 20일
Can you attach a draft of the code you are using? I suppose you started modifying things.
matlabuser12
matlabuser12 2014년 5월 20일
I haven't really modified the mainddd you posted earlier much at all.Tried to incorporate a find after the n = find(~cellfun(@isempty,strfind(header,str))==1,1); line but am not sure that is the right place for this.
Since then been stuck at trying to convert the inputted timespan to seconds since I was just told that the graph needs to have 0-6hrs on the X axis in seconds. The way that the person currently does this is have a data column of [1:.0003:6] and they just plot against that every time. They are using excel though so that means it doesnt matter if the X-Y data size doesnt match but in matlab if the user selects a time span that is not equal to that many seconds it will never plot and just crash.

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

카테고리

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