To plot two functions but it shows unrecognized variable.

12 ビュー (過去 30 日間)
VIDHYA HARINI
VIDHYA HARINI 2023 年 1 月 7 日
編集済み: Torsten 2023 年 1 月 7 日
Hi everyone, I have a doubt, kindly please help me with it.
I need to find graphs for f(x) = e^x-1 and g(x) = 1-x^2 and plot them in the same graph and I also need to find their intersections and area between those two curves.
I am new to this matlab, so I am not really sure how to do this. I hope if there is someone who can help me out with this.
THANK YOU IN ADVANCE.

採用された回答

Image Analyst
Image Analyst 2023 年 1 月 7 日
Here's a start?
x = linspace(-1.5, 1.2, 1000);
f = exp(x)-1 ;
g = 1-x.^2 ;
plot(x, f, 'r-', 'LineWidth', 2);
hold on;
grid on;
plot(x, g, 'b-', 'LineWidth', 2);
xline(0, 'LineWidth', 2)
yline(0, 'LineWidth', 2)
To find the intersection, see the links Star referred you to.
  3 件のコメント
VIDHYA HARINI
VIDHYA HARINI 2023 年 1 月 7 日
And may I know why did you use this? Is that mandatory?
x = linspace(-1.5, 1.2, 1000);
Torsten
Torsten 2023 年 1 月 7 日
編集済み: Torsten 2023 年 1 月 7 日
Do you have a better idea on how to fix the interval and the granularity of the plot ?
To make a plot, you have to fix the interval over which the function is to be plotted and the distance of the points within this interval where the function is evaluated.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by