フィルターのクリア

Sir I want to know how to draw multiple curves in matlab without using the sine function

1 回表示 (過去 30 日間)
has mein
has mein 2017 年 2 月 12 日
コメント済み: Star Strider 2017 年 2 月 12 日
I want to draw curves not straight lines. Kindly help me. If I use the linspace function it asks me function, but I only have values instead of that.
I want to draw multiple curves without using function. I have these values how to plot a smooth curves
[-.7 .35 -.35 1.4]
[-.9 0 -.4 .96]
[-1.1 -.07-.5 .8]
[0 30 60 90]

回答 (2 件)

Star Strider
Star Strider 2017 年 2 月 12 日
See if this does what you want. It uses ‘pchip’ interpolation, not the sine function. For more details, see the documentation for the interp1 function.
The Code
y = [[-.7 .35 -.35 1.4]
[-.9 0 -.4 .96]
[-1.1 -.07 -.5 .8]];
x = [0 30 60 90];
xi = [0:0.5:90];
yi = interp1(x', y', xi, 'pchip');
figure(1)
plot(x, y, 'pk')
hold on
plot(xi, yi, '--k')
hold off
grid
The Plot
  3 件のコメント
Image Analyst
Image Analyst 2017 年 2 月 12 日
There are 181 points there. He just didn't plot them all because there are so many and they're so close together they're hard to see. Try this change:
plot(xi, yi, '--.k', 'MarkerSize', 10)
and maximize the figure to full screen. You'll be able to see lots of points in between the original 4 training points.
Star Strider
Star Strider 2017 年 2 月 12 日
@has mein — What do you intend with ‘gives me grid do not gives grid off points’? The ‘yi’ variable is a matrix of interpolated points matching your original matrix (transposed, since interp1 wants column vectors, and you can easily transpose them again to match your original matrix).
Please explain what you want in more detail.
@Image Analyst — Thank you!

サインインしてコメントする。


Abhay Mohan
Abhay Mohan 2017 年 2 月 12 日
Any curve in matlab is essentially obtained by joining straight lines. This is because MATLAB only has discrete values as it has limited memory. Continuous functions require infinite memory. however, you can make the curve look continuous if you have enough samples. If you already have data points, to get a smooth curve, you will have to interpolate it using the curve fitting tool. To use this, first enter the x and y data as variables. Then use the cftool command to launch curve fitting toolbox. How to use this is explained here .
  1 件のコメント
Image Analyst
Image Analyst 2017 年 2 月 12 日
has mein's "Answer" moved here since it's a comment to the above answer, not an answer itself:
Thank you for your reply sir, but I want to create multiple curves not a single curve. Since it was in my project I am struggling for that. Using curve fitting I can't fit multiple curves. Anyway thanks for your humble reply in this late night. Thank you so much. Using hold on option also can't help me.

サインインしてコメントする。

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by