what is the mistake i am doing here? i have to plot the three equations f,f1,f2

1 view (last 30 days)
Suryans Barmecha
Suryans Barmecha on 20 Nov 2021
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: ")
Critical points are:
disp([xc,yc,zc])
disp('l1 and l2 are:')
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:')
maximum value is:
disp(P)
6
Q=subs(F,{x,y,z},{xc1,yc1,zc1});
disp('minimum value is:')
minimum value is:
disp(Q)
6
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}) ;
Error using plot3
Data must be numeric, datetime, duration or an array convertible to double.
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}) ;

Answers (1)

Alamanda Ponappa Poovaya
Alamanda Ponappa Poovaya on 23 Nov 2021
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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by