What kind of trouble?
finding max and min of function graph
1 次查看(过去 30 天)
显示 更早的评论
Having trouble with last part of code: finding max and min. here is my code:
x = -10:1:10;
y = x;
[xGrid,yGrid] = meshgrid(x,y);
z = (1./((xGrid+3).^2 + (yGrid-1).^2 + 2)) + ((xGrid-yGrid) ./ ((xGrid-1) .^2 + (yGrid-2) .^2 + 4));
subplot(2,2,1)
surf(x,y,z)
title('Isometric View')
xlabel('X')
ylabel('Y')
zlabel('Z')
subplot(2,2,2)
surf(x,y,z)
az=0;
el=90;
view(az,el)
title('View Normal to X-Y Plane')
xlabel('X')
ylabel('Y')
zlabel('Z')
subplot(2,2,3)
surf(x,y,z)
view(0,0)
title('View Normal to X-Z Plane')
xlabel('X')
ylabel('Y')
zlabel('Z')
subplot(2,2,4)
surf(x,y,z)
az=90;
el=0;
view(az,el)
title('View Normal to Y-Z Plane')
xlabel('X')
ylabel('Y')
zlabel('Z')
NegFunction = @(x)(1./((x+3).^2 + (y-1).^2 + 2)) + ((x-y) ./ ((x-1) .^2 + (y-2) .^2 + 4));
[xyMaxVector,zMax] = fminsearch(NegFunction,[0,3]);
xMax = xyMaxVector(1);
yMax = xyMaxVector(2);
fprintf('The Max Value was: z(%6.3f,%6.3f) = %2.0f\n',xMax,yMax,-zMax)
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!