Using for loop in matlab

2 ビュー (過去 30 日間)
Aftab Ahmed Khan
Aftab Ahmed Khan 2015 年 2 月 2 日
編集済み: Matt J 2015 年 2 月 2 日
Hi everyone, I am assigning these values not in a very efficient way, can you suggest me how can i do it more efficiently? Thank you so much.
%Zone 1
absx(1,81)=0;
absy(1,81)=0;
absx(1,82)=0;
absy(1,82)=0;
absx(1,83)=450;
absy(1,83)=0;
absx(1,84)=450;
absy(1,84)=0;
absx(1,85)=450;
absy(1,85)=450;
absx(1,86)=450;
absy(1,86)=450;
absx(1,87)=0;
absy(1,87)=450;
absx(1,88)=0;
absy(1,88)=450;
%Zone 2
absx(1,89)=0;
absy(1,89)=900;
absx(1,90)=0;
absy(1,90)=900;
absx(1,91)=450;
absy(1,91)=900;
absx(1,92)=450;
absy(1,92)=900;
absx(1,93)=450;
absy(1,93)=1350;
absx(1,94)=450;
absy(1,94)=1350;
absx(1,95)=0;
absy(1,95)=1350;
absx(1,96)=0;
absy(1,96)=1350;
%Zone 3
absx(1,97)=900;
absy(1,97)=0;
absx(1,98)=900;
absy(1,98)=0;
absx(1,99)=900+450;
absy(1,99)=0;
absx(1,100)=900+450;
absy(1,100)=0;
absx(1,101)=900+450;
absy(1,101)=450;
absx(1,102)=900+450;
absy(1,102)=450;
absx(1,103)=900;
absy(1,103)=450;
absx(1,104)=900;
absy(1,104)=450;
%Zone 4
absx(1,105)=900;
absy(1,105)=900;
absx(1,106)=900;
absy(1,106)=900;
absx(1,107)=900+450;
absy(1,107)=900;
absx(1,108)=900+450;
absy(1,108)=900;
absx(1,109)=900+450;
absy(1,109)=900+450;
absx(1,110)=900+450;
absy(1,110)=900+450;
absx(1,111)=900;
absy(1,111)=1350;
absx(1,112)=900;
absy(1,112)=1350;
  2 件のコメント
Andreas Goser
Andreas Goser 2015 年 2 月 2 日
Why do you think it is not efficient?
Aftab Ahmed Khan
Aftab Ahmed Khan 2015 年 2 月 2 日
Well, its like 60 lines of code for doing a simple task. I am sure it can be done more efficently in a for loop.

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

採用された回答

Matt J
Matt J 2015 年 2 月 2 日
編集済み: Matt J 2015 年 2 月 2 日
You would do things like the following
absx=zeros(1,112);
absy=zeros(1,112);
%Zone 1
absx(83:86)=450;
absy(85:88)=450
and similarly for the other Zones.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeElementary Math についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by