I am trying to create a matlab variable that correlates with a vector.
조회 수: 2 (최근 30일)
이전 댓글 표시
The given vector in my problem is v34= [1:100}. I have to create a MATLAB variable v1 that adds 9 to each one of its 100 elements and a MATLAB variable v2 that adds 3 to each of its odd elements. I have tried using start values and nElements but i keep on getting an error. Am i supposed to use nElements for this kind of problem?
댓글 수: 1
Sagar Damle
2014년 2월 23일
Does 'odd elements' mean 'elements with odd index'?
e.g. v34(1),v34(3),v34(43) etc. are the odd elements which you want?
채택된 답변
John D'Errico
2014년 2월 23일
편집: John D'Errico
2014년 2월 23일
What does 1:2:end do for you (inside the parens)? Thus
v34(1:2:end)
Think about how you might use this idea, adding 3 to the elements of interest.
As for adding 9, surely you can add 9 to the entire vector in a trivial way. TRY IT!
If you don't try things and see what happens, you won't learn.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!