필터 지우기
필터 지우기

cannot enter = symbol

조회 수: 1 (최근 30일)
Alex
Alex 2024년 4월 8일
댓글: Cris LaPierre 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개)

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by