matlab已知函数值求自变量,

问题描述:

matlab已知函数值求自变量,
y=1/x*(5/6+1/6*x*x)^3
求x
y依次为1.0534,1.2314,1.4561,1.6919,1.9177,2.1429,2.29,2.4383.
x取值范围在1~4之间.

代码如下:
f=@(x,a)1./x.*(5/6+1/6.*x.^2).^3-a;
y=[1.0534,1.2314,1.4561,1.6919,1.9177,2.1429,2.29,2.4383];
x=fsolve(f,2.5*ones(size(y)),[],y);
或者
f=@(x,a)1./x.*(5/6+1/6.*x.^2).^3-a;
y=[1.0534,1.2314,1.4561,1.6919,1.9177,2.1429,2.29,2.4383];
for i=1:length(y);
x(i)=fzero(f,2.5,[],y(i));
end
x =
Columns 1 through 6
1.2679 1.5762 1.8156 2.0031 2.1495 2.2744
Columns 7 through 8
2.3475 2.4158