Read Excel file in Matlab and plot data

조회 수: 12 (최근 30일)
Angel Lozada
Angel Lozada 2025년 10월 6일 16:54
답변: Star Strider 2025년 10월 6일 17:12
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일 17:12
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일 17:11
You need
data = readtable('HUAM1709.041_v2.xlsx');
When your provided filename has an extension, readtable does not attempt to add default extensions.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by