Plot like a "scope" block
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 !
0 comentarios
Respuesta aceptada
Más respuestas (3)
Paulo Silva
el 13 de Mayo de 2011
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'])
![](https://www.mathworks.com/matlabcentral/images/broken_image.png)
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'])
Sébastien Malengé
el 16 de Mayo de 2011
1 comentario
Arnaud Miege
el 16 de Mayo de 2011
The function is just there to generate the data, you can ignore it.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!