Matlab: Reading in data from an excel spreadsheet as a single integer

6 ビュー (過去 30 日間)
Louis
Louis 2011 年 12 月 22 日
I am reading in data from an excel spreadsheet, but I am unable to use a comparison on what I read in. How can I read in a cell from an excel spreadsheet and compare what I get to a number? I'm pretty sure anything read from a spreadsheet is made into an array Here is the relevant code (edit: I'll give the whole code of what I have; edit2: Minor fixes, but being so new to MatLab, I think I'm not familiar with how to declare a variable):
>> for k = 2:4997
colF = 'F';
colE = 'E';
row = int2str(k);
entryF = strcat(colF, row);
entryE = strcat(colE,row);
millisecond = xlsread('someFile.xlsx', 1, entryE);
[~,message] = xlsread('someFile.xlsx', 1, entryF);
if millisecond == 1
soundMoment = 0;
elseif strcmp(message, 'probe_sound')
soundMoment = millisecond;
end
if soundMoment == 0
xlswrite('someFile.xlsx', 'preprobe', 1, entryF);
elseif millisecond > soundMoment
xlswrite('someFile.xlsx', 'postprobe', 1, entryF);
end
end
  25 件のコメント
Aldin
Aldin 2011 年 12 月 23 日
In MATLAB there is no declaration such as in JAVA we have int, float, double, string...
Aldin
Aldin 2011 年 12 月 23 日
Did that do what you want? If so, mark it as "solved."

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

回答 (2 件)

Aldin
Aldin 2011 年 12 月 22 日
Here is the right code for getting data from excel doc.
[~,name] = xlsread('test.xlsx',1,'A1')

Aldin
Aldin 2011 年 12 月 22 日
Edit your code with this:
[~,message] = xlsread('someFile.xlsx', 1, entryF);
your code seems to be OK

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by