Change elements by a set amount.
Ältere Kommentare anzeigen
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 Kommentare
Jay
am 20 Okt. 2014
Bearbeitet: Image Analyst
am 20 Okt. 2014
Image Analyst
am 20 Okt. 2014
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.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Detection finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!