fsurf not drawing cant explain

8 vues (au cours des 30 derniers jours)
Xinhua
Xinhua le 29 Avr 2019
Commenté : David Wilson le 30 Avr 2019
Try these script below
clear
syms x y z;
f1= 0.594693*x - 0.037385*y - 4.415084e-48*(1.410081e94*x^2 - 1.010367e94*x*y - 7.167399e96*x - 6.594237e94*y^2 + 4.505749e95*y + 8.942503e98)^(1/2) - 26.520424;
f2= 0.594693*x - 0.037385*y + 4.415084e-48*(1.410081e94*x^2 - 1.010367e94*x*y - 7.167399e96*x - 6.594237e94*y^2 + 4.505749e95*y + 8.942503e98)^(1/2) - 26.520424;
fsurf(f1,'FaceColor','red')
hold on
fsurf(f2,'FaceColor','green')
hold off
xlabel('x');
ylabel('y');
zlabel('z');
It produce empty drawing.there are some big numbers in the equation but the final value should be within +-200.No reason it doesn't draw.

Réponses (1)

David Wilson
David Wilson le 29 Avr 2019
Modifié(e) : David Wilson le 29 Avr 2019
Do you really need to use the symbolic toolbox? Why not just plot a numerical surface? But you are right, your numbers are widely varying and your surfaces are fairly flat.
Below I just took arbitrary ranges.
clear
f1= @(x,y) 0.594693*x - 0.037385*y - 4.415084e-48*(1.410081e94*x.^2 - 1.010367e94*x.*y - 7.167399e96*x - ...
6.594237e94*y.^2 + 4.505749e95*y + 8.942503e98).^(1/2) - 26.520424;
f2= @(x,y) 0.594693*x - 0.037385*y + 4.415084e-48*(1.410081e94*x.^2 - 1.010367e94*x.*y - 7.167399e96*x - ...
6.594237e94*y.^2 + 4.505749e95*y + 8.942503e98).^(1/2) - 26.520424;
xv = linspace(-2,2,20)'; yv = linspace(-3,5,30)';
[X,Y] = meshgrid(xv,yv)
F1 = f1(X,Y);
F2 = f2(X,Y);
surf(xv, yv, F1)
hold on
surf(xv, yv, F2)
hold off
  2 commentaires
Xinhua
Xinhua le 30 Avr 2019
the problem is if I took the range too wide it will produce complex number and it will not draw either and I cant manuelly calculate ranges for every graph I draw.A corret image should produce a cone shape.untitled.jpg
David Wilson
David Wilson le 30 Avr 2019
One ugly solution is to identify where the complex regions are and then "NaN" them.
It's not overly pretty this way, but can be made better with a finer grid. You could always try fimplicit3 if not satisfied.
clear
f1= @(x,y) 0.594693*x - 0.037385*y - 4.415084e-48*(1.410081e94*x.^2 - 1.010367e94*x.*y - 7.167399e96*x - ...
6.594237e94*y.^2 + 4.505749e95*y + 8.942503e98).^(1/2) - 26.520424;
f2= @(x,y) 0.594693*x - 0.037385*y + 4.415084e-48*(1.410081e94*x.^2 - 1.010367e94*x.*y - 7.167399e96*x - ...
6.594237e94*y.^2 + 4.505749e95*y + 8.942503e98).^(1/2) - 26.520424;
% Now use a wide range
yv = linspace(-300,400,150)';
xv = linspace(-300,-120,130)';
[X,Y] = meshgrid(xv,yv)
F1 = f1(X,Y);
F2 = f2(X,Y);
F1(find(imag(F1)~=0)) = NaN; % drop complex parts
F2(find(imag(F2)~=0)) = NaN;
%
surf(xv, yv, real(F1))
hold on
surf(xv, yv, real(F2))
hold off
shading interp
lighting phong
camlight left
tmp.png

Connectez-vous pour commenter.

Catégories

En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by