Invalid Syntax at '='.Possibly,a ),} or ] is missing at line 6 .

조회 수: 3 (최근 30일)
swathi sunkaraboina
swathi sunkaraboina 2019년 2월 6일
편집: James Tursa 2019년 2월 6일
function [y1,y2,y3] = fnc(u)
%#codegen
y1=0;y2=0;y3=0;
if 0<=u<=(pi/3)
{
y1=1; ----------------------Error:Invalid Syntax at '='.Possibly,a ),} or ] is missing at line 6
y2=-1;
y3=0
}-------------------------Error:Parse error at }:Usage might be invalid Matlab syntax.
if((pi/3)<u<=(2*pi/3))
{y1=1;
y2=0;
y3=-1;
}
if((2*pi/3)<u<=(pi))
{y1=0;
y2=1;
y3=-1;
}
end;

채택된 답변

James Tursa
James Tursa 2019년 2월 6일
편집: James Tursa 2019년 2월 6일
The { } formulation for blocking code is not valid MATLAB syntax. To fix this:
  • Get rid of the open brace {
  • Replace the close brace } with end
I.e., instead of
if something
{
stuff;
}
Do this
if something
stuff;
end
  댓글 수: 1
Steven Lord
Steven Lord 2019년 2월 6일
In addition to what James wrote, this syntax doesn't do what I believe you think it does.
if 0<=u<=(pi/3)
If you open that file in the MATLAB Editor, you should see a Code Analyzer message on those lines explaining what it does and how to do what you want. I believe there may even be an auto-fix available.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by