Filter löschen
Filter löschen

cannot enter = symbol

1 Ansicht (letzte 30 Tage)
Alex
Alex am 8 Apr. 2024
Kommentiert: Cris LaPierre am 8 Apr. 2024
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.

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 8 Apr. 2024
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 Kommentare
Alex
Alex am 8 Apr. 2024
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 am 8 Apr. 2024
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;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by