How to generate a signal

6 visualizaciones (últimos 30 días)
Ricardo Duarte
Ricardo Duarte el 7 de En. de 2022
Comentada: Star Strider el 7 de En. de 2022
Dear all,
I want to generate a signal similar to the one in the following picture (black line only).
How can I do that.
I tried to do it by hand and I obtained the next picture
The thing is that I need more resolution (I have now 41 points and I need to have 4096). How can I do that?
Thanks in advance,
  1 comentario
Image Analyst
Image Analyst el 7 de En. de 2022
What does "do it by hand" mean? How did you actually get that second plot above?
Do you mean that you had an image of the graph and you used something like drawfreehand() to hand-trace the curve? And then plotted the coordinates that you traced? If you need more than drawfreehand() gave you, you can just use interp1().

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 7 de En. de 2022
I would use the interp1 function —
x = linspace(0, 0.015, 41); % Independent Variable
y = randn(size(x)); % Synthesize Signal
xi = linspace(min(x), max(x), 4096);
yi = interp1(x, y, xi, 'linear');
figure
subplot(2,1,1)
plot(x, y, '.-')
grid
title('Original Signal')
subplot(2,1,2)
plot(xi, yi, '.-')
grid
title('Interpolated Original Signal Shjowing Interpolated Points')
figure
subplot(2,1,1)
plot(x, y, '.-')
grid
title('Original Signal')
xlim([4.1 4.15]*1E-3)
subplot(2,1,2)
plot(xi, yi, '.-')
grid
title('Interpolated Original Signal Shjowing Interpolated Points')
xlim([4.1 4.15]*1E-3)
sgtitle('Enlarged To Show Detail')
The original and interpolated vectors are plotted as dots connected by lines.
.
  2 comentarios
Ricardo Duarte
Ricardo Duarte el 7 de En. de 2022
Thank you very much! It was exactly this what I wanted!
Star Strider
Star Strider el 7 de En. de 2022
As always, my pleasure!
.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by