How can I subtract consecutive numbers from one starting point?

1 vue (au cours des 30 derniers jours)
maximumdv
maximumdv le 12 Fév 2019
Commenté : Jos (10584) le 12 Fév 2019
Hello everyone,
So I have an array which I want to subtract from a starting point. Lets say I have a list of numbers [1,2,3,4 etc.] and I would like to subtract these from 200. So 200-1=199, 199-2=197, 197-3=194, 194-4=190. How can I do this. I need the array to maintain the same amount of vectors to plot my graph afterwards.
Thank you in advance.
  1 commentaire
Jos (10584)
Jos (10584) le 12 Fév 2019
I do not know what "I need the array to maintain the same amount of vectors to plot my graph afterwards." means, but see my answer below :-)

Connectez-vous pour commenter.

Réponse acceptée

Jos (10584)
Jos (10584) le 12 Fév 2019
L = 1:4
SP = 200
R = SP - cumsum(L)

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by