Why there is a Invalid Expresssion error in my fit function?

1 回表示 (過去 30 日間)
Hyeon Soo Lee
Hyeon Soo Lee 2023 年 5 月 19 日
コメント済み: Hyeon Soo Lee 2023 年 5 月 19 日
I wrote this simple code
n = [1433;2700;1000000];
s = [1170.98;780.65;390.33];
f= fit(n,s,'power1')
But the error said "invalid expression. check for missing or extra characters"
I'm not very used to Matlab and I absolutely have no idea why this error occurs.
Ofc, I installed Curve Fitting Toolbox

採用された回答

the cyclist
the cyclist 2023 年 5 月 19 日
Your code works:
n = [1433;2700;1000000];
s = [1170.98;780.65;390.33];
f= fit(n,s,'power1')
f =
General model Power1: f(x) = a*x^b Coefficients (with 95% confidence bounds): a = 3511 (-3.081e+04, 3.783e+04) b = -0.167 (-1.38, 1.046)
Did you perhaps try to spread that code across multple lines? You might need to use line continuation, if so.
  3 件のコメント
the cyclist
the cyclist 2023 年 5 月 19 日
It's difficult to understand what is going on with your code, when it works perfectly fine here.
Do you get this problem from a freshly restarted MATLAB session? How are you calling these lines of code?
Are you sure you have the CF toolbox installed? What do you get if you type
which -all fit
from the command line?
Hyeon Soo Lee
Hyeon Soo Lee 2023 年 5 月 19 日
Problem solved. Seems like my labtop was gone crazy for a while. It works fine now. Thanks for the help btw.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

製品


リリース

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by