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!