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!