Borrar filtros
Borrar filtros

cannot enter = symbol

27 visualizaciones (últimos 30 días)
Alex
Alex el 8 de Abr. de 2024 a las 14:44
Comentada: Cris LaPierre el 8 de Abr. de 2024 a las 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.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 8 de Abr. de 2024 a las 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 comentarios
Alex
Alex el 8 de Abr. de 2024 a las 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 el 8 de Abr. de 2024 a las 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;

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by