fsurf not drawing cant explain

8 次查看(过去 30 天)
Xinhua
Xinhua 2019-4-29
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.

回答(1 个)

David Wilson
David Wilson 2019-4-29
编辑:David Wilson 2019-4-29
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 个评论
Xinhua
Xinhua 2019-4-30
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 2019-4-30
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by