Clear Filters
Clear Filters

How to generate a signal

3 views (last 30 days)
Ricardo Duarte
Ricardo Duarte on 7 Jan 2022
Commented: Star Strider on 7 Jan 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 Comment
Image Analyst
Image Analyst on 7 Jan 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().

Sign in to comment.

Accepted Answer

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

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!