for | Error: Expression or statement is incomplete or incorrect.

Rm=[0:10]
Xm=[5 7 9]
Zm=[10 5 7]
for
i=1:3
Rm=[0:10]
n(i)=abs(Xm-Rm)
Rs(Rm)=sqrt((n.^2)+(Zm.^2))
end

2 件のコメント

Stephen23
Stephen23 2017 年 5 月 15 日
Badly aligned code with commands split over multiple lines... what could possibly go wrong?
What do you expect the output to be?
Jan
Jan 2017 年 5 月 15 日
@Ahmed: I've formatted your code. Do you see the orphaned "for" line now?

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

 採用された回答

Torsten
Torsten 2017 年 5 月 15 日

1 投票

Rm = [0:10];
Xm = [5 7 9];
Zm = [10 5 7];
for i=1:11
for j=1:3
dist(i,j) = sqrt((Rm(i)-Xm(j))^2+Zm(j)^2);
end
end
Best wishes
Torsten.

その他の回答 (1 件)

KSSV
KSSV 2017 年 5 月 15 日

0 投票

Xm=[5 7 9] ;
Zm=[10 5 7] ;
Rm=linspace(1,10,length(Xm)) ;
Rs = zeros(size(Xm)) ;
for i=1:3
n=abs(Xm(i)-Rm(i)) ;
Rs(i)=sqrt((n.^2)+(Zm(i).^2)) ;
end

カテゴリ

ヘルプ センター および File Exchange で MATLAB についてさらに検索

タグ

タグが未入力です。

質問済み:

2017 年 5 月 15 日

コメント済み:

Jan
2017 年 5 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by