Reading different columns from excel in Matlab

2 ビュー (過去 30 日間)
Johan Sebastian Diaz Tovar
Johan Sebastian Diaz Tovar 2018 年 11 月 2 日
コメント済み: madhan ravi 2018 年 11 月 2 日
Hello, I'm trying to read different datas that belong to the same excel file, for that I made this code:
abs = 'icv bac abs fluor 250918.csv';
data = xlsread(abs);
[rows, columns] = size(data);
for col = 1 : 2 : columns
x = data(3:603, col);
y = data(3:603, col + 1);
plot(x, y, '-', 'LineWidth', 2);
hold on;
end
grid on;
However, I'm getting this error: Index exceeds matrix dimensions. Enclosed in this questions is the file that I'm working with. Thank u.

採用された回答

Caglar
Caglar 2018 年 11 月 2 日
編集済み: Caglar 2018 年 11 月 2 日
As a weird feature, xlsread ignores rows that does not include any number. Therefore your 'data' variable is 601 x n. Read data as raw, then you will protect excel structure,
[~,~,data] = xlsread(abs);
Note that data is now cell and you need to convert it back to numerics (I guess).
data=cell2mat(data);
Or you can just,
data = xlsread(abs);
x = data(1:601, col);

その他の回答 (1 件)

madhan ravi
madhan ravi 2018 年 11 月 2 日
abs = 'icv bac abs fluor 250918.csv';
[num,~,~] = xlsread(abs);
data = num;
[rows, columns] = size(data);
for col = 1 : 2 : columns
x = data(3:603, col);
y = data(3:603, col + 1);
plot(x, y, '-', 'LineWidth', 2);
hold on;
end
grid on;
  1 件のコメント
madhan ravi
madhan ravi 2018 年 11 月 2 日
The above should do the trick you want

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

カテゴリ

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