How to generate a signal

6 次查看(过去 30 天)
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 个评论
Image Analyst
Image Analyst 2022-1-7
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().

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2022-1-7
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 个评论
Ricardo Duarte
Ricardo Duarte 2022-1-7
Thank you very much! It was exactly this what I wanted!
Star Strider
Star Strider 2022-1-7
As always, my pleasure!
.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by