已经一组自变量X 如何用matlab计算隐函数的值并作图

2025-01-20 21:12:03
推荐回答(3个)
回答1:

(1)在定义域内画出图像

ezplot('sin((x-y)*pi/180)-0.5*sin(x*pi/180)*sin(y*pi/180)=0',[-40,30])

(2)在定义域内将x 10等分 求出10个相应的函数值Y

i=0;
for x=-40:10:30
i=i+1,x
s=vpa(solve(sin((x-y)*pi/180)-0.5*sin(x*pi/180)*sin(y*pi/180)));
real(s)
end

i =
1
x =
-40
ans =
-55.326313395244617595807318688513
i =
2
x =
-30
ans =
-39.064678388593601202348454283034
i =
3
x =
-20
ans =
-23.986351844912709757536690462716
i =
4
x =
-10
ans =
-10.944522776791502516790074350449
i =
5
x =
0
ans =
0.0
i =
6
x =
10
ans =
9.204256078555759453116900181748
i =
7
x =
20
ans =
17.115238008652834072613850945404
i =
8
x =
30
ans =
24.133261210456048305814917300791

回答2:

1、隐函数绘图可用
ezplot('sin(x-y)-0.5*sin(x)*sin(y)',[-40 30]*pi/180,[-1 .5])

2、其实你的这个方程可以求解:
syms x y
f=sin(x-y)-0.5*sin(x)*sin(y);
y=solve(f,y)
可以求出y的表达式
y=
atan(2*sin(x)/(2*cos(x)+sin(x)))
有了表达式,很容易可以求出x对应的y值:
subs(y,linspace(-40,30,10)*pi/180)

3、需要说明的是,y是多值函数,用这个命令可以看出:
ezplot('sin(x-y)-0.5*sin(x)*sin(y)',[-40 30]*pi/180,[-10 10])

回答3:

x=-40/180:7/180:30/180
y=atan(2*sin(x)./(2*cos(x)+sin(x)))
plot(x,y)

x =
-0.2222 -0.1833 -0.1444 -0.1056 -0.0667 -0.0278 0.0111 0.0500 0.0889 0.1278 0.1667
y =
-0.2494 -0.2016 -0.1556 -0.1114 -0.0690 -0.0282 0.0110 0.0488 0.0851 0.1201 0.1539