Clear Filters
Clear Filters

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

1 view (last 30 days)
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.

Accepted Answer

Walter Roberson
Walter Roberson on 19 Jul 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.

More Answers (1)

Chunru
Chunru on 19 Jul 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

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!