Meshgrid fo variables in complex equation

I have an equation that have three variables
The equation is like this : f(x, y, z)=2x+3y+4z=0
But the equation I really want to use is more complex that I can’t turn it into
z=(-3y-2x)/4 format like this
And I want to draw a plot about the relation between the three(x, y, z) when
x = 3: 1:6; (3,4,5,6)
y = 5: 1:9; (5,6,7,8,9)
I know that if I can turn the equation into z=(-3y-2x)/4 format, I can do that using
x=3:1:6;
y=5:1:9;
[xx,yy]=meshgrid(x,y);
zz=(-3.*yy-2.*xx)/4;
mesh(xx,yy,zz);
But because the equation I really want to use is too complex, I can’t use the method to get the answer I want
I also try the other way using for loop
i=1
for x= 3:1:6
for y= 5:1:9
syms f(z)
f=2*x+3*y+4*z;
answer=solve(f);
answer2(i)=answer;
x1(i)=x;
y1(i)=y;
i=i+1;
end
end
answer3=double(answer2);
[x2,y2]=meshgrid(x1,y1);
But still don’t know the next process
Can I have other methods to use, or can I revise the methods above to solve my problem?
I am new to matlab, and i really need your help, thank you!

 Respuesta aceptada

Stephan
Stephan el 15 de Abr. de 2021
Editada: Stephan el 15 de Abr. de 2021
You might want to try fimplicit3:
syms f(x,y,z)
f(x, y, z)=2*x+3*y+4*z==0
f(x, y, z) = 
fimplicit3(f)
or an even more complex example:
f(x, y, z)=2*sin(x)+tanh(3*y)+exp(z/4)==0
f(x, y, z) = 
fimplicit3(f)

3 comentarios

Thank you very much for your answer, that's very helpful to me. But I also have another question, when I want to add an interval
syms f(x,y,z)
f(x,y,z)=2.*x+3.*y+4.*z==0
interval=[3 6 5 9 0 5];
fimplicit3(f,interval)
it will get
But when I use
syms f(x,y,z)
f(x,y,z)=2.*x+3.*y+4.*z==0
interval=[-3 6 -5 9 0 5];
fimplicit3(f,interval)
It can get
Is that because the interval I set must be negative to positive when I use the fimplicit3?
Thanks again for your useful suggestion and reply!
HSIUYUAN WANG
HSIUYUAN WANG el 16 de Abr. de 2021
I'll try that later, thank you very much!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 15 de Abr. de 2021

Comentada:

el 16 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by