How to define time vectors using different sampling rates and plot.
Mostrar comentarios más antiguos
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

Respuesta aceptada
Más respuestas (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
1 comentario
Charles Naegele
el 18 de Mayo de 2018
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!