Create a function and plot it
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
pauldjn
le 6 Juin 2019
Réponse apportée : Akira Agata
le 6 Juin 2019
Hello I have the following function:
f(x) = 1 + a/ 2.5 + x
a= some value
I would like to plot that function. I try to do it with a loop but it takes a lot of time when my x interval is too large.
for x = 1:1000
a= 500
fx = 1 + (a/ (2.5 + x));
plot(x,fx,'-*', 'color','blue');
hold on;
end
Is there other way to plot the function maybe defining it with the matlab function command?
0 commentaires
Réponse acceptée
Akira Agata
le 6 Juin 2019
There are two ways to do this.
[Solution 1]
a = 500;
x = 1:1000;
fx = 1 + (a ./ (2.5 + x));
figure
plot(x,fx)
[Solution 2]
a = 500;
fx = @(x) 1 + (a ./ (2.5 + x));
figure
fplot(fx,[1 1000])
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Performance dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!