Meshgrid fo variables in complex equation

조회 수: 9 (최근 30일)
HSIUYUAN WANG
HSIUYUAN WANG 2021년 4월 15일
댓글: HSIUYUAN WANG 2021년 4월 16일
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!

채택된 답변

Stephan
Stephan 2021년 4월 15일
편집: Stephan 2021년 4월 15일
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
HSIUYUAN WANG
HSIUYUAN WANG 2021년 4월 16일
I'll try that later, thank you very much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by