How to define time vectors using different sampling rates and plot.
이전 댓글 표시
I have 3 data columns (3000x1) which were sampled at 10Hz, 35Hz, and 100Hz. I want to define a time vector for each of these columns that will allow me to plot them together against time.
if true
% code
end
% SAMPLED AT 10Hz, SMALL ORIFICE
ts = 0:(1/10):(3000/10)-(1/10);
p1small = importdata('Psmall.txt');
psmall = p1small(:,2);
figure
plot(ts,psmall)
hold on
% SAMPLED AT 35Hz, MEDIUM ORIFICE
tm = 0:1/35:(3000/35)-(1/35);
p1med = importdata('Pmed.txt');
pmed = p1med(:,2);
plot(tm,pmed)
hold on
% SAMPLED AT 100Hz, LARGE ORIFICE
tl = 0:1/100:(3000/100)-(1/100);
p1large = importdata('Plarge.txt');
plarge = p1large(:,2);
plot(tl,plarge)
hold off

채택된 답변
추가 답변 (1개)
You have the right idea. The convention is
startValue:stepSize:EndValue
t=0:0.1:300
will give 3001 samples at 0.1 step size. To get exactly 3000 samples, just take one step off the end:
t=0:0.1:300-0.1
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!