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

조회 수: 1 (최근 30일)
SAHIL SAHOO
SAHIL SAHOO 2022년 7월 19일
답변: Walter Roberson 2022년 7월 19일
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.

채택된 답변

Walter Roberson
Walter Roberson 2022년 7월 19일
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.

추가 답변 (1개)

Chunru
Chunru 2022년 7월 19일
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

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by