how to plot a symbolic equation with 4 variables?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Does anyone know how to plot a symbolic equation containing 4 variables? u=f(x,y,z) using colour as the fourth dimension for u?
Thanks a lot!
0 commentaires
Réponse acceptée
Walter Roberson
le 1 Avr 2013
Assuming that f is a symbolic expression in x, y, z, then:
ufun = matlabFunction(f, 'vars', {'x', 'y', 'z'});
xrange = linspace(-10, 10, 50); %for example
yrange = linspace(-pi, 3*pi/2, 50); %for example
zrange = linspace(1, 2, 57); %for example
[X, Y, Z] = ndgrid(xrange, yrange, zrange);
u = ufun(X, Y, Z);
pointsize = 10; %adjust as needed
scatter3(X, Y, Z, pointsize, u);
colormap(copper(256)); %choose appropriate colormap
2 commentaires
Walter Roberson
le 1 Avr 2013
scatter3(X(:), Y(:), Z(:), 10, U(:))
Warning: this is pretty slow for 200 x 200 x 200! Expect slowdowns to start once you get bigger than about 21 x 21 x 21. On my system, 50 x 50 x 50 is still peppy "enough" to draw originally, but rotating it is becoming clumsy. 200 x 200 x 200 took on the order of a minute or more to draw -- even just closing the figure took a good 30 seconds.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox 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!