I have a code but it keeps sending this erreur message : Error: File: moo_objective_functions.m Line: 4 Column: 89 Invalid expression. When calling a function or indexing a va
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Here's the code :
- function f = moo_objective_functions (x)
- dispo = x(1) ; rule = x(2); iat= x(3) ; bs =x(4) ;
- f(1) = 144633 - [(13633* bs) - (5742.6 *iat) - (68028* rule) - (71627* dispo) + (542.4 *
- bs*iat) + (6511* bs*rule) + (6809 *bs*dispo) + (2721.8 *iat*rule) + (2845.2* iat*dispo)
- + (33807* rule*dispo) - (260.52* bs*iat*rule) - (269.48 *bs*iat*dispo) - (3235.7
- *bs*rule*dispo) - (1352.5 *iat*rule*dispo) + (129.46* bs*iat*rule*dispo)] ;
- f(2) = -[-61.61 + 9.883* bs + 4.1508* iat + 2.415* rule + 98.713* dispo -
- (0.50632* bs*iat)- (9.4912* bs*dispo) - (0.0971* iat*rule) - (3.9333 *iat*dispo) -
- (1.116* rule*dispo)+ (0.37771* bs*iat*dispo) + (0.0448* iat*rule*dispo)] ;
- end
and this is the 2 erreur messages :
Error: File: moo_objective_functions.m Line: 4 Column: 89
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched
delimiters.
Error: File: moo_objective_functions.m Line: 4 Column: 89
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched
delimiters.
0 Kommentare
Antworten (1)
Harshavardhan
am 7 Mär. 2025
The error messages you're encountering suggest that there is a problem with the syntax in your MATLAB code, specifically with the use of brackets and parentheses. When splitting a statement across multiple lines in MATLAB, use the ellipsis ” ... “ to indicate that the statement continues on the next line. The code with the correct syntax is given below:
function f = moo_objective_functions (x)
dispo = x(1) ; rule = x(2); iat= x(3) ; bs =x(4) ;
f(1) = 144633 - ((13633* bs) - (5742.6 *iat) - (68028* rule) - (71627* dispo) + (542.4 * bs*iat) ...
+ (6511* bs*rule) + (6809 *bs*dispo) + (2721.8 *iat*rule) + (2845.2* iat*dispo) ...
+ (33807* rule*dispo) - (260.52* bs*iat*rule) - (269.48 *bs*iat*dispo) - (3235.7*bs*rule*dispo) ...
- (1352.5 *iat*rule*dispo) + (129.46* bs*iat*rule*dispo)) ;
f(2) = -(-61.61 + 9.883* bs + 4.1508* iat + 2.415* rule + 98.713* dispo ...
- (0.50632* bs*iat)- (9.4912* bs*dispo) - (0.0971* iat*rule) - (3.9333 *iat*dispo) ...
- (1.116* rule*dispo)+ (0.37771* bs*iat*dispo) + (0.0448* iat*rule*dispo)) ;
end
For more information on ellipsis in MATLAB, you can refer to the following link:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!