早教吧 育儿知识 作业答案 考试题库 百科 知识分享

matlab求解含三角函数的方程请问用MATLAB如何求解y=sqrt(1-sin(x)^2)+sin(x)的根,x的范围是0到2*pi,万分感激!

题目详情
matlab求解含三角函数的方程
请问用MATLAB如何求解y=sqrt(1-sin(x)^2)+sin(x)的根,x的范围是0到2*pi,万分感激!
▼优质解答
答案和解析
y=@(x)sqrt(1-sin(x).^2)+sin(x);
fplot(y,[0,2*pi])
hold on
ezplot('0',[0,2*pi])%看图知道在4和5.5附近有根
fun=@(x)[y(x);y(x)];
x=fsolve(fun,[4;5.5])
y(x)
Optimization terminated:directional derivative along
search direction less than TolFun and infinity-norm of
gradient less than 10*(TolFun+TolX).
x =
3.9270
5.4978
ans =
1.0e-012 *
0.2262
0.0525