creating vectors with for loops

1 回表示 (過去 30 日間)
steve guy
steve guy 2013 年 2 月 24 日
I am trying to create the following vectors using for loops
a=[1:7:91]
c=a(2:3:9)
Do I look to be on the right track? I don't have software to test with at the moment.
n=1; %initialize a's index
b=1; %initialize index for c
N=91;
for x=1:7:N
a(n)=x;
n=n+1;
end
for y=a
c(b)=a(2:3:9)
b=b+1;
end

採用された回答

Image Analyst
Image Analyst 2013 年 2 月 24 日
Not your last for loop. Try
n = 1;
for k = 2:3:9
c(n)=a(k);
n = n + 1;
end
  1 件のコメント
steve guy
steve guy 2013 年 2 月 24 日
thank you. this makes a lot of sense. I can see my mistake.

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

その他の回答 (0 件)

カテゴリ

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