Change elements by a set amount.
Afficher commentaires plus anciens
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 commentaires
Jay
le 20 Oct 2014
Modifié(e) : Image Analyst
le 20 Oct 2014
Image Analyst
le 20 Oct 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.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Detection dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!