Have problem in solution
古いコメントを表示
I'm new to Matlab and I have a problem with this solution on line 14. Please give me for any advice. Thank you

2 件のコメント
John D'Errico
2021 年 9 月 23 日
When you post code, post it as text, not a picture of text. Otherwise, you force someone to type in your entire code, unless they can see an obvious error. If you want help, then make it easy for someone to help you.
Ratchapon Nilprapa
2021 年 9 月 26 日
採用された回答
その他の回答 (1 件)
Walter Roberson
2021 年 9 月 23 日
編集済み: Walter Roberson
2021 年 9 月 23 日
Erf=[0.2 0.6 0.7333];
Erf is a vector.
y=(-0.3725*(Erf)^2)+(1.2144*(Erf))+(0.0006);
You have Erf^2 . But in MATLAB, the ^ operator is repeated matrix multiplication -- so Erf^2 is (Erf*Erf) where * is the algebraic matrix multiplication operator, also known as Inner Product. For Inner Product A*B, the number of columns of A (the first operand) must be the same as the number of rows of B (the second operand) . You hae a 1 x 3 vector, so you effectively have (1 x 3) * (1 x 3), but the number of columns in the first operand, 3, does not match the number of rows in the second (1).
You probably want the element-by-element power operator, which in MATLAB is the .^ operator
y=(-0.3725*(Erf).^2)+(1.2144*(Erf))+(0.0006);
Be careful: your line 19 completely overwrites y, overwriting the value assigned to y in line 18.
Note: it is easier for the volunteers to assist you if you post code, instead of posting pictures of code. Don't make the volunteers type out the code by hand in order to test it or point out which parts of it have difficulties.
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!