Script work - hard to explain in title

6 visualizaciones (últimos 30 días)
mikev438
mikev438 el 6 de Nov. de 2013
Comentada: mikev438 el 6 de Nov. de 2013
Hey guys, basically I need to produce a script that will ask for a set of values. The values then need to be added up in backwards order and put onto a graph. So for example, if the user entered [2, 3, 5, 7]. I would need my y values to be (7, 7+5, 7+5+3, 7+5+3+2). I hope this makes sense.
I've started with:
'x = input('Enter values for distance of each load from A:');
z = input('Enter values for each load:');
plot(x,y);'
I'm just struggling to think of a command I can use to produce my y values as said before. Any help would be great, once I get this sorted I can really start moving forwards with this!

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 6 de Nov. de 2013
A=[2, 3, 5, 7]
cumsum(fliplr(A))
  3 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 6 de Nov. de 2013
A=[2, 3, 5, 7]
out=fliplr(cumsum(fliplr(A)))
mikev438
mikev438 el 6 de Nov. de 2013
That's brilliant, thank you so much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by