如何在Matlab中求解x的函数?
我定义了这个函数:如何在Matlab中求解x的函数?,matlab,octave,Matlab,Octave,我定义了这个函数: % Enter the data that was recorded into two vectors, mass and period mass = 0 : 200 : 1200; period = [0.404841 0.444772 0.486921 0.522002 0.558513 0.589238 0.622942]; % Calculate a line of best fit for the data using polyfit() p = polyfit(
% Enter the data that was recorded into two vectors, mass and period
mass = 0 : 200 : 1200;
period = [0.404841 0.444772 0.486921 0.522002 0.558513 0.589238 0.622942];
% Calculate a line of best fit for the data using polyfit()
p = polyfit(mass, period, 1);
fit=@(x) p(1).*x + p(2);
现在我想解f(x)=.440086,但找不到一种方法。我知道我可以很容易地用手算出来,但我想知道将来怎么做。如果你想解一个线性方程,比如
a*x+B=0
,你可以很容易地在MATLAB中求解,如下所示:
p=[0.2 0.5];
constValue=0.440086;
A=p(1);
B=constValue-p(2);
soln=A\B;
如果你想解一个非线性方程组,你可以使用fsolve
,如下所示(这里我将展示如何使用它来解上述线性方程):
这两种方法应提供相同的解决方案。如果要求解线性方程,如
a*x+B=0
,可以在MATLAB中轻松求解,如下所示:
p=[0.2 0.5];
constValue=0.440086;
A=p(1);
B=constValue-p(2);
soln=A\B;
如果你想解一个非线性方程组,你可以使用fsolve
,如下所示(这里我将展示如何使用它来解上述线性方程):
这两种方法应提供相同的解决方案。如果要求解线性方程,如
a*x+B=0
,可以在MATLAB中轻松求解,如下所示:
p=[0.2 0.5];
constValue=0.440086;
A=p(1);
B=constValue-p(2);
soln=A\B;
如果你想解一个非线性方程组,你可以使用fsolve
,如下所示(这里我将展示如何使用它来解上述线性方程):
这两种方法应提供相同的解决方案。如果要求解线性方程,如
a*x+B=0
,可以在MATLAB中轻松求解,如下所示:
p=[0.2 0.5];
constValue=0.440086;
A=p(1);
B=constValue-p(2);
soln=A\B;
如果你想解一个非线性方程组,你可以使用fsolve
,如下所示(这里我将展示如何使用它来解上述线性方程):
这两种方法应该提供相同的解决方案