Plot parabola with start, end and vertex points

35 ビュー (過去 30 日間)
Freyja
Freyja 2013 年 11 月 10 日
コメント済み: Freyja 2013 年 11 月 11 日
Hi,
So I have three points and I would like matlab to plot them as a parabola. The points represent the path of a balls projectile motion and I know the start (0,0), end (2.062, 0) and high point (1.031, 0,73) of the parabola.
What I would like most would be to plot these points as a parabola and also calculate the equation for the parabola.
Thanks in advance :)
Freyja

採用された回答

Roger Stafford
Roger Stafford 2013 年 11 月 11 日
Another way to get the parabola is to write:
y = 0.73-a*(x-1.031)^2
which is the form it must have to peak at (1.031,0,73) and then set x and y to zero to force the parabola to contain (0,0) and solve for a. The solution is obvious. Then do a plot.
  1 件のコメント
Freyja
Freyja 2013 年 11 月 11 日
Ok, well I worked out the value for a and then wrote a function, I'm sure matlab could have worked it out for me but I don't know how. So I did the easy way and plotted the range I wanted and it gave me a parabola!
So thanks a lot for the help. This is the code that worked for me...
x = (0:0.01:2.06);
y = 0.73-0.68676.*(x-1.031).^2;
plot(x,y,'LineWidth',3,'color',[1,0.5,0])
Many thanks!

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

その他の回答 (1 件)

Matt J
Matt J 2013 年 11 月 11 日
編集済み: Matt J 2013 年 11 月 11 日
You can use POLYFIT to fit a parabola to the points. Then you can use POLYVAL to sample and plot it.
  4 件のコメント
Matt J
Matt J 2013 年 11 月 11 日
But this gave me a triangle....not a parabola....
It only looks like a triangle, because you didn't plot at enough points
xu=linspace(0,2.06,1000);
plot(xu, polyval(p, xu));
Freyja
Freyja 2013 年 11 月 11 日
Oh I see, thankyou, i will try that :)

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

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by