How do i multiply this matrix to work in MATLAB, it keeps sending an error

2 ビュー (過去 30 日間)
Carine
Carine 2024 年 9 月 26 日
コメント済み: Cris LaPierre 2024 年 9 月 26 日

(3^.5)*sind(x)*(p.)+cosd(x)*(p.)-800

  1 件のコメント
Cris LaPierre
Cris LaPierre 2024 年 9 月 26 日
What are the values of your variables x and p?
What is the full error message (all the red text)?
You should probably remove the dot after p. as that may be causing your error.
p = 5;
p.
Invalid expression. Check for missing or extra characters.

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

回答 (1 件)

Steven Lord
Steven Lord 2024 年 9 月 26 日
What did you expect to happen when you typed p. in your expression? That's not valid MATLAB syntax. If you had a number instead of p, that would have been valid because that period would be interpreted as a decimal point.
x = 0:30.:180; % same as 0:30:180 or 0:30.0:180
y1 = (3^.5)*sind(x)*(2.)+cosd(x)*(2.)-800 % number, trailing decimal point, works
y1 = 1×7
-798.0000 -796.5359 -796.0000 -796.5359 -798.0000 -800.0000 -802.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
p = 2;
y2 = (3^.5)*sind(x)*(p)+cosd(x)*(p)-800 % variable name, no period, works
y2 = 1×7
-798.0000 -796.5359 -796.0000 -796.5359 -798.0000 -800.0000 -802.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% y3 = (3^.5)*sind(x)*(p.)+cosd(x)*(p.)-800 % variable name, period, would not work

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by