필터 지우기
필터 지우기

fsurf not drawing cant explain

조회 수: 2 (최근 30일)
Xinhua
Xinhua 2019년 4월 29일
댓글: David Wilson 2019년 4월 30일
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