Finding correct data row in excel data file

2 ビュー (過去 30 日間)
Aadil
Aadil 2012 年 8 月 9 日
Hi,
I have excel data files which I read and process in matlab, sometimes the logged data shifts and starts at row 10 instead of row 8, is there a way for matlab to automatically find where the data starts without having to manually set the row?
Below is a screenshot of what I mean:
Thanks

採用された回答

Sriram
Sriram 2012 年 8 月 9 日
編集済み: Sriram 2012 年 8 月 9 日
If you are sure that all your input file starts with the same string "Parameter PC Timest..... " or "SourceAddress" as like what you have shown in the image.... If that's the case, you can use any of the following which might suit yours
strcmp % Compare strings with case sensitive
strcmpi % Compare strings
strncmp % for first n characters
strncmpi
To get the text fields from xlsread use
[num,txt,raw] =xlsread('filename') % check matlab help for more info
Compare the text filed and later try to access the data by appending the rows from the compared string "true" row..! Hope you can understand..:)
This might the simple and best way that can help you and I am sure Matlab by itself automatically can't know what's your files data starting point :P
  3 件のコメント
Sriram
Sriram 2012 年 8 月 10 日
[numbers,texts,full] = xlsread('filename');
cmp = strcmpi ('Parameter',texts);
row_nums = find(cmp==1);
Now cell's row with word parameter is available in row_nums !
Aadil
Aadil 2012 年 8 月 13 日
Worked, thanks!

サインインしてコメントする。

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 8 月 10 日
that depends on what kind of data you have, string, numbers,...
[num,text,num_text]=xlsread(YourFile)
  1. num contains numeric data (class double)
  2. text contains string data (class cell)
  3. num_textt contains both numeric and string (class cell)
you don't need to know where are your data, unless there other contents then your matrix of data.

カテゴリ

Help Center および File ExchangeData Import from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by