plotting functions from book

6 ビュー (過去 30 日間)
Faisal Al-Wazir
Faisal Al-Wazir 2022 年 10 月 1 日
コメント済み: Faisal Al-Wazir 2022 年 10 月 2 日
hi i'm trying to plot this function and get the same result from the book
the function:
the plot in the book;
this is my code
i need to find a way to make the plot smother
c=1
c = 1
for k=1.2:0.4:2.8
u=linspace(0,2.8,5)
u1=0:0.01:2,4
f=(k/c).*(u/c).^(k-1).*exp(-(u/c).^(k))
plot(u,f)
hold on
end
u = 1×5
0 0.7000 1.4000 2.1000 2.8000
u1 = 1×201
0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900
ans = 4
f = 1×5
0 0.5823 0.2871 0.1218 0.0473
u = 1×5
0 0.7000 1.4000 2.1000 2.8000
u1 = 1×201
0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900
ans = 4
f = 1×5
0 0.7341 0.3530 0.0942 0.0165
u = 1×5
0 0.7000 1.4000 2.1000 2.8000
u1 = 1×201
0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900
ans = 4
f = 1×5
0 0.8577 0.3944 0.0511 0.0022
u = 1×5
0 0.7000 1.4000 2.1000 2.8000
u1 = 1×201
0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900
ans = 4
f = 1×5
0 0.9524 0.4083 0.0180 0.0001
u = 1×5
0 0.7000 1.4000 2.1000 2.8000
u1 = 1×201
0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0600 0.0700 0.0800 0.0900 0.1000 0.1100 0.1200 0.1300 0.1400 0.1500 0.1600 0.1700 0.1800 0.1900 0.2000 0.2100 0.2200 0.2300 0.2400 0.2500 0.2600 0.2700 0.2800 0.2900
ans = 4
f = 1×5
0 1.0194 0.3945 0.0036 0.0000

採用された回答

Torsten
Torsten 2022 年 10 月 1 日
編集済み: Torsten 2022 年 10 月 1 日
c = 1;
k = 1.2:0.4:2.8;
u = (linspace(0,2.4,100)).';
f = (k/c).*(u/c).^(k-1).*exp(-(u/c).^(k));
plot(u,f)
  2 件のコメント
Ethan McDonald
Ethan McDonald 2022 年 10 月 1 日
I believe Torsten's solutions solves your issue, but I wanted to comment to let you know you should avoid using for-loops when possible. Matlab is much quicker at processing vectos and matrices, and in many case, you can take advantage of GPU computing for large amounts of data.
Faisal Al-Wazir
Faisal Al-Wazir 2022 年 10 月 2 日
thanks i'll keep that in mind

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by