plotting as a function of x
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have no problem ploting as a function of y but when i try replicating it and plotting it as a function of x i get an error or the image comes out wrong.
In this case i want to plot x = y.^1/3 (y=x^3) as a function of x bounded by x=1 , y = 1 and y=0
i used this code when doing it as a function of y
f = @(x) x.^3;
g = @(x) x-x;
fplot(f, [-3, 3]), hold on
fplot(g, [-3, 3], 'LineWidth',2)
x1 = 0;
x3 = 1;
xcoord = linspace(x1, x3, 100);
ycoord = [f(xcoord); g(xcoord)];
plot([xcoord;xcoord], ycoord),
plot(xline(1))
hold off
But i can't seem to replicate it using a function of x.
Thanks
0 commentaires
Réponses (1)
Walter Roberson
le 29 Oct 2022
x = y.^1/3
MATLAB would parse that as being x = (y.^1)/3 which is x = y/3 which is not what you want.
If you were to use x = y.^(1/3) then that would be closer. However, you would encounter the problem that P.^Q is defined as being equivalent to exp(Q*log(P)) -- and log() of a negative number is complex, so if the power Q is not an even integer, the result is going to be complex.
0 commentaires
Voir également
Catégories
En savoir plus sur Debugging and Analysis 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!