Change elements by a set amount.
古いコメントを表示
I have a vector that goes up in twos:
delta= 2 2 4 4 6 6
What function can I use so that:
delta= 2 2 3 3 4 4 ?
2 件のコメント
Jay
2014 年 10 月 20 日
編集済み: Image Analyst
2014 年 10 月 20 日
Image Analyst
2014 年 10 月 20 日
He didn't say to do all that stuff. You added code that broke it. Just do what he said. Like I did:
delta= [2 2 4 4 6 6]
delta = delta - delta/2 + 1
In the command window you'll see
delta =
2 2 4 4 6 6
delta =
2 2 3 3 4 4
exactly as you asked for. Of course since you didn't specify what algorithm was to be used, just simply that you wanted a function to return [2,2,3,3,4,4], I was going to suggest this function:
function delta = JustinsFunction(delta)
delta = [2,2,3,3,4,4];
That also meets all your stated requirements, more than Mischa's actually because I actually created a function and he did not - he just used operators.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Detection についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!