Illegal use of reserved keyword "end"
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi,
I have some problems with my code. I get 'Illegal use of reserved keyword "end"' command.
for z2=[0:0.01:max([a2,a3,a4,a5,a6,a7,a11,a13,a17,a19,a23,a25,a29,a31,a35,a37])]
if z2 > d2(length(a2))
e2=[1 1];
s2=[a2(length(a2)) max([a2,a3,a4,a5,a6,a7,a11,a13,a17,a19,a23,a25,a29,a31,a35,a37]);
plot(s2,100*e2,'color',[0.8500 0.3250 0.0980],'LineWidth',2)
end
end
Where as a result:
a2=[ 0 0.0090 0.0170 0.0260 0.0870 0.0960 0.1050 0.1130 0.1220 0.1310 0.1400 0.1570 0.1660 0.1740 0.1830 0.1920 0.2010 0.2090 0.2180 0.2270 0.2360 0.2440 0.2530 0.2620 0.2880 0.3050 0.3140 0.3230 0.3310]
d2=1
z2=[0:0.01:1.6310]
댓글 수: 0
채택된 답변
the cyclist
2020년 12월 27일
In the statement
s2=[a2(length(a2)) max([a2,a3,a4,a5,a6,a7,a11,a13,a17,a19,a23,a25,a29,a31,a35,a37]);
you seem to have missed the closing square bracket to create the two-element vector s2. This leads to the very non-intuitive error message you got, because MATLAB hits that end statement in an unexpected way.
추가 답변 (1개)
marie lasz
2020년 12월 27일
you missed a closing of a square bracket.
s2=[a2(length(a2)) max([a2,a3,a4,a5,a6,a7,a11,a13,a17,a19,a23,a25,a29,a31,a35,a37]);
plot(s2,100*e2,'color',[0.8500 0.3250 0.0980],'LineWidth',2)]
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!