xlsread with changing starting point
2 ビュー (過去 30 日間)
古いコメントを表示
Hello all,
I've had some questions before, and everytime I did get an answer, so now I will try it again.
I'm using matlab to get some data out of a Excel document.
At the moment I'm using this code:
dir_struct = dir('*.xlsx');
for i = 1:numel(dir_struct)
number(i) = str2double(dir_struct(i).name(10:(10+numel(dir_struct(i).name)-16))); % get the number-string out of the filename and turn it into a number (I have fixed the format there)
end
[revised_numbers, order] = sort(number);
for i = 1:numel(order)
[num, tekst, raw] = xlsread(dir_struct(order(i)).name,'MISC','B9:C16');
I've received this code in a question earlier. I wanted to use xlsread, but the excel file changes in name over time, so the part where the excel file is mentioned, is now numerical.
This code works fine for me.
My next problem has this code involved.
In the worksheet MISC, the matrix defined is now B9:C16. B9 is i=1, B10 is i=2 etc.
Now, the start of i=1 changes. At the moment, B9 is i=1. But in the future, B12 or B13 for example can be i=1.
What I want is the following code, if possible ofcourse.
Above the data that I want, there is always the text: "Simulation input".
Is it possible for matlab, to 'search' the column B for this text, and set that cell to i=1? So that the place of the start can be everywhere in column B.
I hope that this is clear for you to understand. If not, I will change it and I will try to make it more sence.
I would like to thank you in advance!
Greets, Bart
0 件のコメント
回答 (2 件)
Image Analyst
2013 年 9 月 11 日
You can use ismember() to search your column for particular text string. It will give you the row(s) where it was found. Then set them to 1.
9 件のコメント
Image Analyst
2013 年 9 月 25 日
Attaching your workbook to your message would make it easier if someone wants to try something. I can't get to it for several hours, if at all.
参考
カテゴリ
Help Center および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!