Clear Filters
Clear Filters

cannot enter = symbol

27 views (last 30 days)
Alex
Alex on 8 Apr 2024 at 14:44
Commented: Cris LaPierre on 8 Apr 2024 at 15:13
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.

Accepted Answer

Cris LaPierre
Cris LaPierre on 8 Apr 2024 at 14:54
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 Comments
Alex
Alex on 8 Apr 2024 at 15:01
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 on 8 Apr 2024 at 15:13
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;

Sign in to comment.

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!