I am trying to write some code that will average every two elements in a vector. However, when I run my program the vectors aren't changed. Is there some scope issue?
xData=ones(11,1)
yDataInner=ones(11,1)
yDataOuter=ones(11,1)
for i=[1,23]
if mod(i,2)==0
xData(i/2)=mean(V(i),V(i-1))
yDataInner(i/2)=mean(sineInner(i),sineInner(i-1))
yDataOuter(i/2)=mean(sineOuter(i),sineOuter(i-1))
end
end

 채택된 답변

per isakson
per isakson 2017년 10월 10일
편집: per isakson 2017년 10월 10일

0 개 추천

Replace
for i=[1,23]
by
for i=1:23
and look up for in the documentation.
Your code will run the loop only for i==1 and i==23

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2017년 10월 10일

편집:

2017년 10월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by