Hi, my question :
Can I use plot to watch a curve like a scope block do when you put 'scope parameters' sampling to 'Sample time' and no to 'decimal' ?
Thanks !

 채택된 답변

Sébastien Malengé
Sébastien Malengé 2011년 5월 16일

0 개 추천

I find my happiness with stairs ! (and not plot...)
Thanks.

추가 답변 (3개)

Paulo Silva
Paulo Silva 2011년 5월 13일

0 개 추천

Answer edited, looking better at the scope it looks like it does something like the ZOH block does, maybe this code can help you:
Ts1=0.01; %sampling time in seconds of the measured signal
%if you don't know Ts1 do Ts1=t(2)-t(1)
t=0:Ts1:10;
f=@(x)sin(x); %function that generates the signal
s=f(t);
Ts=0.1; %sampling time in seconds of your sampling (Ts must be bigger than Ts1)
sss=cell2mat(arrayfun(@(x)repmat(s(x),1,fix(Ts/Ts1)),1:fix(Ts/Ts1):numel(s),'uni',false));
clf
hold on
plot(t,s)
plot(t,sss(1:numel(t)),'r')
legend('signal',['signal sampled at ' num2str(Ts) ' seconds'])
Example that I wrote but it doesn't do the same as the scope:
t=0:0.01:10;
f=@(x)sin(x); %function that generates the signal
s=f(t);
Ts=1; %sampling time in seconds
tsamp=0:Ts:10;
ssamp=f(tsamp);
clf
hold on
plot(t,s)
plot(tsamp,ssamp,'r')
legend('signal',['signal sampled at ' num2str(Ts) ' seconds'])

댓글 수: 1

Sébastien Malengé
Sébastien Malengé 2011년 5월 16일
In my case, I have a problem with the length of my curve, I can't use your code if the length is different, so that doesn't work...

댓글을 달려면 로그인하십시오.

Sébastien Malengé
Sébastien Malengé 2011년 5월 16일

0 개 추천

In my case, I don't have a function like you, I just have a curve in a variable, so where I suppose to put my curve in the code ? Thanks by the way.

댓글 수: 1

Arnaud Miege
Arnaud Miege 2011년 5월 16일
The function is just there to generate the data, you can ignore it.

댓글을 달려면 로그인하십시오.

Arnaud Miege
Arnaud Miege 2011년 5월 16일

0 개 추천

You can also use simplot.
HTH
Arnaud

Community Treasure Hunt

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

Start Hunting!

Translated by