cannot enter = symbol

1 次查看(过去 30 天)
Alex
Alex 2024-4-8
I'm getting invalid use of operator warnings when defining variables
clc
clear all
rho = 1025 %kg/m^3 - Seawater Density
c_d = 0.7 % Drag Coefficient (gentils, wang et al, 2017)
c_m = 2.0 % Inetia Coefficient
% Note: current is neligible
% Calulate wave length (Lamda)
g = 9.81; % gravity
T = 12 % secs - 8.3.1 corewind 1.2 Isle of Barra
H = 8 % m - 8.3.1 corewind 1.2 Isle of Barra
d = 120 % m - depth of column Table 3-1 OC3 Floating Paltform
lambda = ((g*T^2/2pi)tan*(H))(2pi*d/lambda)
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
----------------------------------------------------------------------------------------
>> MorrisonsEqn
File: MorrisonsEqn.m Line: 4 Column: 1
Invalid use of operator.
>> MorrisonsEqn
File: MorrisonsEqn.m Line: 4 Column: 1
Invalid use of operator.
>> MorrisonsEqn
File: MorrisonsEqn.m Line: 17 Column: 19
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct
matrices, use brackets instead of parentheses.
>> MorrisonsEqn
File: MorrisonsEqn.m Line: 15 Column: 19
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To
construct matrices, use brackets instead of parentheses.
>> MorrisonsEqn
File: MorrisonsEqn.m Line: 15 Column: 19
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To
construct matrices, use brackets instead of parentheses.

采纳的回答

Cris LaPierre
Cris LaPierre 2024-4-8
There is no implied multiplication. Also, the syntax for using tan is incorrect.
lambda = ((g*T^2/(2*pi))*tan(H))*(2*pi*d/lambda)
% ^^^^^^ ^ x ^ ^
clc
clear all
rho = 1025 %kg/m^3 - Seawater Density
rho = 1025
c_d = 0.7 % Drag Coefficient (gentils, wang et al, 2017)
c_d = 0.7000
c_m = 2.0 % Inetia Coefficient
c_m = 2
% Note: current is neligible
% Calulate wave length (Lamda)
g = 9.81; % gravity
T = 12 % secs - 8.3.1 corewind 1.2 Isle of Barra
T = 12
H = 8 % m - 8.3.1 corewind 1.2 Isle of Barra
H = 8
d = 120 % m - depth of column Table 3-1 OC3 Floating Paltform
d = 120
lambda = ((g*T^2/2/pi)*tan(H))*(2*pi*d/lambda)
Unrecognized function or variable 'lambda'.
The new error is because you cannot use a variable that has not yet been defined.
  2 个评论
Alex
Alex 2024-4-8
Thanks but why is it highlighting the equals signs yellow on every line, and an error on line 4.
Much appreciated
Cris LaPierre
Cris LaPierre 2024-4-8
That is a warning letting you know those lines will print to the screen. To get rid of the yellow highlight, add a semicolon at the end of the line.
x=2
x = 2
% vs
y=3;

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by