creating vectors with for loops

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일

0 개 추천

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개)

카테고리

도움말 센터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!

Translated by