Read Excel file in Matlab and plot data

5 ビュー (過去 30 日間)
Angel Lozada
Angel Lozada 2025 年 10 月 6 日
回答済み: Star Strider 2025 年 10 月 6 日
I am trying to plot the cloumn 2 (amplitude) vs column 1 (time).
However, I am getting the same error:
Error using readtable (line 19)
Unable to find or open 'HUAM1709.041_v2'. Check the path and filename or file permissions.
Error in
data = readtable('HUAM1709.041_v2');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Once I solve this inquiry I will be able to plot the other 2 amplitudes vs time.
Could you help yo identify the error?
Both .m file and excel file are in the same folder.
Attached will find excel file.
Thanks in advance.
T = data(:,1);
T = seconds(data(:,1));
T.Format = 'hh:mm';
T2 = data(:,2);
figure; % Place "figure" in this section allow to plot this data in a separate window.
plot (T,T2,'.');
title 'Accelerometer';
ylabel ('Amplitude');
xlabel ('Samples');

採用された回答

Star Strider
Star Strider 2025 年 10 月 6 日
Use curly braces {} to access data in a table.
data = readtable('HUAM1709.041_v2.xlsx')
data = 24205×4 table
Var1 Var2 Var3 Var4 _____ _______ _______ _______ 0 -0.0157 0.0107 0.0111 0.001 -0.0758 0.0469 0.0666 0.002 0.0612 -0.0408 -0.0544 0.003 0.0336 -0.0217 -0.0299 0.004 -0.0843 0.0514 0.0757 0.005 0.0203 -0.0118 -0.0166 0.006 0.0733 -0.046 -0.0622 0.007 -0.0646 0.04 0.0563 0.008 -0.0326 0.0207 0.0275 0.009 0.0863 -0.0513 -0.0724 0.01 -0.0209 0.017 0.0189 0.011 -0.0723 0.0441 0.0642 0.012 0.0668 -0.0397 -0.0556 0.013 0.0312 -0.0193 -0.0294 0.014 -0.0839 0.0517 0.0748 0.015 0.0207 -0.0104 -0.017
% return
T = data{:,1};
T = seconds(data{:,1});
T.Format = 'hh:mm';
T2 = data{:,2};
figure; % Place "figure" in this section allow to plot this data in a separate window.
plot (T,T2,'.');
title 'Accelerometer';
ylabel ('Amplitude');
xlabel ('Samples');
With those changes, you code works.
.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2025 年 10 月 6 日
You need
data = readtable('HUAM1709.041_v2.xlsx');
When your provided filename has an extension, readtable does not attempt to add default extensions.

カテゴリ

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

製品


リリース

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by