Azzera filtri
Azzera filtri

couldn't understand what's wrong in the function definition.

1 visualizzazione (ultimi 30 giorni)
f = @(t,y) [
((y(2)-a-l.*(abs(cos(y(3)+ pi/4)))).*y(1) + k.*y(1).*cos(y(3)- pi/2)).*(2/tc);
(P - (y(2).*(y(1) + 1))) / tf;
o - (k./tc).*2.* sin(y(3)));
];
getting a problem
"Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for
mismatched delimiters." in this.

Risposta accettata

Walter Roberson
Walter Roberson il 19 Lug 2022
o - (k./tc).*2.* sin(y(3)));
1 0 1 2 10!
the digits are the nesting level "after" the character above. You open and then close brackets, leaving zero open brackets. You then open two brackets... and you close three brackets, one more than you opened.

Più risposte (1)

Chunru
Chunru il 19 Lug 2022
a =1; P=2; i=3; tf=4; k=5; l=6; tc=7; o=8;
f = @(t,y) [ ( (y(2)-a-l.*(abs(cos(y(3)+ pi/4)) )).*y(1) + k.*y(1).*cos(y(3)- pi/2)).*(2/tc);
(P - (y(2).*(y(1) + 1))) / tf;
o - (k./tc).*2.* sin(y(3)) ]
f = function_handle with value:
@(t,y)[((y(2)-a-l.*(abs(cos(y(3)+pi/4)))).*y(1)+k.*y(1).*cos(y(3)-pi/2)).*(2/tc);(P-(y(2).*(y(1)+1)))/tf;o-(k./tc).*2.*sin(y(3))]
f(1, [1; 2; 2])
ans = 3×1
-0.0220 -0.5000 6.7010

Categorie

Scopri di più su Read, Write, and Modify Image in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by