plotting one variable function

13 ビュー (過去 30 日間)
danish ansari
danish ansari 2020 年 12 月 9 日
回答済み: Star Strider 2020 年 12 月 9 日
i want to plot a graph:
y axis: 4/(1+Ri)^2
xaxis: (1+Ri)/(2*(1-Ri)) : it should vary from 2 to 25
Ri is the only variabe.
i tried with both fplot and plot command but both are giving me different plot.
just want to know what is the correct method to plot this.?

採用された回答

Walter Roberson
Walter Roberson 2020 年 12 月 9 日
xfun = @(Ri) (1+Ri)./(2*(1-Ri));
yfun = @(Ri) 4./(1+Ri).^2;
zfun = @(Ri) zeros(size(Ri));
h = fplot3(xfun, yfun, zfun, [3/5, 50/51]); view(2); xlim([2 25]); ylim([1 1.6])
The correct upper bound for Ri should be 49/51 but in practice if you use that, fplot3 cuts off at 19 point something.
  1 件のコメント
danish ansari
danish ansari 2020 年 12 月 9 日
It helps.
Thanks you very much Walter Roberson.

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

その他の回答 (2 件)

Star Strider
Star Strider 2020 年 12 月 9 日
Another approach:
sRi(1) = fsolve(@(Ri) (1+Ri)./(2*(1-Ri)) - 2, 0.01);
sRi(2) = fsolve(@(Ri) (1+Ri)./(2*(1-Ri)) - 25, 0.01);
Ri = linspace(sRi(1), sRi(2));
X = (1+Ri)./(2*(1-Ri));
Y = 4./(1+Ri).^2;
figure
plot(X, Y)
grid
producing:
With ‘X’ going from 2 to 25, as requested.

James Tursa
James Tursa 2020 年 12 月 9 日
Your question is unclear. Is it Ri that varies from 2 to 25? And the y-axis and x-axis formulae you have are the coordinates of (x,y) points for a curve?
Is this what you want:
Ri = 2:0.125:25;
x = (1+Ri) ./ (2*(1-Ri));
y = 4 ./ (1+Ri).^2
plot(x,y);
  1 件のコメント
danish ansari
danish ansari 2020 年 12 月 9 日
on x axis term ''(1+Ri) ./ (2*(1-Ri))" varying from 2 to 25.
yes those are the coordinates for (x,y) points for a curve.

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

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by