what is the mistake i am doing here? i have to plot the three equations f,f1,f2
조회 수: 3 (최근 30일)
이전 댓글 표시
clc
clear all
syms x y z l1 l2 S1 S2 S3
f=2*x+4*y+z^2;
f1=y^2+z^2-1;
f2=x^2+z^2-1;
F=f+l1*f1+l2*f2;
dfx=diff(F,x);
dfy=diff(F,y);
dfz=diff(F,z);
[l1,l2,xc,yc,zc]=solve(f1,f2,dfx,dfy,dfz,'Real',true);
disp("Critical points are: ")
disp([xc,yc,zc])
disp('l1 and l2 are:')
disp([l1,l2])
a=size([xc,yc,zc]);
b=size([l1,l2]);
xc1=max(xc);
yc1=max(yc);
zc1=max(zc);
xc2=min(xc);
yc2=min(yc);
zc2=min(zc);
P=subs(F,{x,y,z},{xc1,yc1,zc1});
disp('maximum value is:')
disp(P)
Q=subs(F,{x,y,z},{xc1,yc1,zc1});
disp('minimum value is:')
disp(Q)
eqs = [f,f1,f2];
[S1,S2,S3]=solve(eqs,[S1,S2,S3]);
S1=double(S1);
S2=double(S2);
S3=double(S3);
plot3(f,f1,f2,{S1,S2,S3}) ;
grid on
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')
error:
Error using plot3
Data must be numeric, datetime, duration or an array convertible to double.
Error in ass3q2 (line 35)
plot3(f,f1,f2,{S1,S2,S3}) ;
댓글 수: 0
답변 (1개)
Drishan Poovaya
2021년 11월 23일
Hi,
It appears you are trying to plot symbolic functions. This is not what plot3 is designed to do, it can only plot numerical values. plot3(x,y,z) requires 3 equal lenght vectors where each triplet [ x(i) y(i) z(i) ] represents a point on the plot.
In order to plot symbolic functions I would suggest you read the following documentation for fplot and fsurf
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Scatter Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!