matlab求交点问题
clc;
clear all;
syms x;
equ=sin(x)-(0.0328112*x.^4 - 0.204917*x.^3 - 0.0145485*x.^2 + 1.05427*x - 0.0261189);
for n=1:5
vpasolve(equ,x,'random',true)
end
上述缺只得到了两个相同的解
有什么办法可以得到全部的解,在固定的区间上。
但是从图像上观察到在0-1区间内应该有很多0点
在0.9到1之间有零点,但是vpasolve求不出来。
%z=sin(x);
%y =0.0328112*x.^4 - 0.204917*x.^3 - 0.0145485*x.^2 + 1.05427*x - 0.0261189;
b=@(x)sin(x)-(0.0328112*x.^4 - 0.204917*x.^3 - 0.0145485*x.^2 + 1.05427*x - 0.0261189);
[x,err]=fzero(b,[0 1])
先看有没有交点,再求交点:
clc;clear;
syms x;
equ=sin(x)-(0.0328112*x.^4 - 0.204917*x.^3 - 0.0145485*x.^2 + 1.05427*x - 0.0261189);
figure(1);clf % 先画图看有没有交点
subplot(2,1,1)
fplot(matlabFunction(equ), [0,1]); grid on;
subplot(2,1,2)
fplot(matlabFunction(equ), [0.9,1]);grid on;
x = vpasolve(equ, 1) % 求得1附近的点
结果在0~1之间只有一个交点
x =
0.98347571207327331876919100339437