Find the difference between two variables

So I have a graph of glacial melt per year and it has 169 variables. I need to know the difference between each point. For example on excel you do b-a=# c-b=# d-c=# and so on down the list. I have tried a few different ‘solutions’ for writing this code but it never works. Please help

Antworten (1)

Matt J
Matt J am 26 Apr. 2018

1 Stimme

See the diff() command.

4 Kommentare

Sitney Day
Sitney Day am 3 Mai 2018
Every time I try this command it tells me there are too many variables. This is a list of 164 that I need the difference between each
Walter Roberson
Walter Roberson am 3 Mai 2018
Make the variables columns in a numeric matrix, provided that they are all the same length.
You should probably be using readtable instead of storing into separate variables.
Stephen23
Stephen23 am 3 Mai 2018
Bearbeitet: Stephen23 am 3 Mai 2018
"Every time I try this command it tells me there are too many variables..."
That is because using 169 individual variables is the wrong way to use MATLAB. That data should be in one variable. Then processing and handling that data would be trivial (e.g. you could simply call diff on it).
Matt J
Matt J am 3 Mai 2018
Bearbeitet: Matt J am 3 Mai 2018
Every time I try this command it tells me there are too many variables.
Before using an unfamiliar command, you should read its documentation to learn its proper usage. In this case, you can see in the documentation for diff that there is no input syntax allowing 169 separate input arguments.

Melden Sie sich an, um zu kommentieren.

Produkte

Gefragt:

am 26 Apr. 2018

Bearbeitet:

am 3 Mai 2018

Community Treasure Hunt

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

Start Hunting!

Translated by