MATLAB Answers

Plotting the the acceleration data of the degree of freedom versus the time.

1 view (last 30 days)
LK
LK on 19 Jul 2021
Commented: LK on 19 Jul 2021
I am given the data for acceleration (almost 3 pages) and the question says that the sampling rate for all of the experiments was 50 Hz (50 samples per second, or delta_t= 0.02 sec. I am supposed to plot the acceleration data vs time and also find the peaks of acceleration that accurs during the free vibration. I loaded the acceleration data file and extracted data from the column but I am not sure how to specify the time data when I am only given the time step and how to mark the peaks. I appreciate the help! I get the following error:
Code:
clc; clear all; close all;
load VibrationSDOF_Data.txt
acc = VibrationSDOF_Data(:,1);
time =[0: 0.02: 110]
plot (time,acc,'r-');
Error:
error using plot
vectors must be the same length

Accepted Answer

Walter Roberson
Walter Roberson on 19 Jul 2021
Change
time =[0: 0.02: 110]
to
dt = 0.02;
time = (0:numel(acc)-1) * dt;
  5 Comments

Sign in to comment.

More Answers (1)

Chunru
Chunru on 19 Jul 2021
Make sure time and acc have the same size
time =[0: length(acc)-1]*0.02;
plot (time,acc,'r-');

Community Treasure Hunt

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

Start Hunting!

Translated by