フィルターのクリア

How to plot two exponential functions on Matlab?

24 ビュー (過去 30 日間)
Amna Habib
Amna Habib 2022 年 3 月 28 日
コメント済み: Amna Habib 2022 年 3 月 30 日
I need to plot the two exponential functions on same graph. Please help me to write code. Thanks in advance.
f(x) = exp(-(((x-2)/3)^2)/2)
g(x) = 1-exp(-(((x-2)/3)^2))

採用された回答

Star Strider
Star Strider 2022 年 3 月 28 日
Another approach —
x = linspace(0, 10);
f = @(x) exp(-(((x-2)/3).^2)/2);
g = @(x) 1-exp(-(((x-2)/3).^2));
figure
plot(x, [f(x); g(x)])
grid
legend('f(x)','g(x)', 'Location','best')
.
  8 件のコメント
Amna Habib
Amna Habib 2022 年 3 月 29 日
Very Nice @Star Strider!
Thanks a lot for sharing your knowledge!
I really apprecciate your effort.
Star Strider
Star Strider 2022 年 3 月 29 日
As always, my pleasure!

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

その他の回答 (1 件)

Sam Chak
Sam Chak 2022 年 3 月 28 日
編集済み: Sam Chak 2022 年 3 月 28 日
Try this:
x = -10:0.01:12;
f = exp(-(((x-2)/3).^2)/2);
g = 1-exp(-(((x-2)/3).^2));
plot(x, f, x, g)
xlabel('x')
legend('f(x)', 'g(x)')
grid on
  6 件のコメント
Torsten
Torsten 2022 年 3 月 29 日
X = -12:0.01:12;
f = zeros(size(X));
g = zeros(size(X));
f(X<=0) = exp(-((X(X<=0)/3).^2)/2);
f(X>0) = exp(-((X(X>0)/2).^2)/2);
g(X<=0) = 1 - exp(-((X(X<=0)/3).^2));
g(X>0) = 1 - exp(-((X(X>0)/2).^2));
h = f.^2 + g.^2;
plot(X,[f;g;h],'linewidth',1.5)
Amna Habib
Amna Habib 2022 年 3 月 30 日
Thanks a lot @Torsten!
I appreciate your effort!

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

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by