Plot serial time data from excel file
Ältere Kommentare anzeigen
Hello.
I am trying to plot data from excel file. Column 2 (amplitude) vs Column 1 (time). The time is in second
Each second the data is sample 200 time.
0.000 (second zero sample zero) => 0.199 (second zero to sample 199) to second 120.004 (120 second. sample 004).
I try writing a code, but I am not able to make it work.
Also, I am trying to plot the results where xlabel show that each second there are 200 samples.
I have try some codes.
% Define the sampling parameters
Fs = 200; % Sampling frequency in Hz
duration = 5.199; % Duration in seconds
t = 0:1/Fs:duration; % Time vector from 0 to 5.199 seconds
% Read data from Excel file
data = readtable('HUAM1709.041_v3.xlsx'); % Replace with your actual file name
amplitude = data.Var2; % Assuming the second column contains the amplitude data
% Ensure the time vector matches the length of the amplitude data
if length(amplitude) ~= length(t)
error('Length of amplitude data does not match the time vector.');
end
% Plot the discrete time series data
figure;
stem(t, amplitude, 'filled'); % Use stem for discrete data representation
xlabel('Time (seconds)');
ylabel('Amplitude');
title('Discrete Time Series Data from 0 to 5.199 seconds');
grid on;
This code was thanks to Star Strider (Level 10 Mathworks)
data = readtable('HUAM1709.041_v2.xlsx')
% 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');
I am looking a plot like the attached file.
Where X axis is going from 0 to 120.
1 Kommentar
imshow(imread('NAA I Amplitude.jpg'))
.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Data Import from MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



