I have a question on plotting a specific part of data from a larger section,

Below shows my code for plotting two waveforms over 12 seconds,the workspace variable D10 is 240001 x 2 double, I am particularly interested in a section of this data between 5 and 8 seconds and I want to plot it separately on its own, several attempts have given errors so any help is much appreciated.
Thanking you in advance
t = [((0:length(D10)-1))]*1/20000; plot (t,D10); xlabel('Time(s)'), ylabel('Pu') title ('Engine and Generator Shaft Speed')

 Accepted Answer

It looks like your sampling frequency is 20 kHz
I'll just create a noise signal as an example
fs = 2e4;
D10 = randn(240001,1);
t = 0:1/fs:(240001*1/fs)-1/fs;
dt = 1/fs;
idxstart = round(5/dt);
idxend = round(8/dt);
plot(t(idxstart:idxend),D10(idxstart:idxend));
set(gca,'xlim',[5 8])
xlabel('Time(s)'), ylabel('Pu'), title ('Engine and Generator Shaft Speed')

1 Comment

Hi Wayne
Thanks for your answer,it has really improved my plotting, however the plot wont display the two graphs contained in the D10 data, to give a little background info the two graphs should show as a reference trajectory (Step input)and a control loop response (Step response), My plot will only show the step input
Thanks again

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!