plotting functions from book
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Faisal Al-Wazir
il 1 Ott 2022
Commentato: Faisal Al-Wazir
il 2 Ott 2022
hi i'm trying to plot this function and get the same result from the book
the function:![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1142370/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1142370/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1142375/image.png)
the plot in the book; ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1142380/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1142380/image.png)
this is my code
i need to find a way to make the plot smother
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
0 Commenti
Risposta accettata
Torsten
il 1 Ott 2022
Modificato: Torsten
il 1 Ott 2022
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 Commenti
Ethan McDonald
il 1 Ott 2022
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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!