Illegal use of reserved keyword "end"

8 ビュー (過去 30 日間)
Aleksandra Pawlak
Aleksandra Pawlak 2020 年 12 月 27 日
コメント済み: Aleksandra Pawlak 2020 年 12 月 27 日
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]

採用された回答

the cyclist
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 件のコメント
Aleksandra Pawlak
Aleksandra Pawlak 2020 年 12 月 27 日
thanks

サインインしてコメントする。

その他の回答 (1 件)

marie lasz
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)]
  1 件のコメント
Aleksandra Pawlak
Aleksandra Pawlak 2020 年 12 月 27 日
thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by