How do I produce a graph of the slope of a group of data points?

I am currently working with a set of historical price points, and I am looking to graph the slope of the changes over time. The data, however, is too erratic to create an effective best fit curve. I am fairly unfamiliar with Matlab. Is there a way to do this effectively?

11 Comments

Probably. People here would need more details to help you efficiently though.
Forgive me, I know my question isn't the clearest. Would it help if I sent you the data? I'd be happy to do anything I can.
No worries. You could always post your data here and see if people are willing to help. However, the best way to get help is to show some effort yourself. Please show what you have tried and ask specific questions.
If there was an easy way to simulate price changes over time, there would be a lot of millionaires around here.
I have attached the data. All I have been able to do is graph it, as I just touched Matlab for the first time about an hour ago. I am looking to make a graph of how the slope changes over time. I'm really quite lost.
I'm not trying to simulate how they will change, just analyze how they did! I wish there was an easy way to predict price changes though! And thank you so much for helping me thus far.
To plot the slope:
plot(diff(your_data))
Since you are just starting with Matlab, I strongly recommend you to read the "Getting started" part of the documentation.
No data attached.
Use the ‘paperclip’ icon next to the ‘Help’ button.
It should be attached now. I entered in the data, but it gives me the error "Difference order N must be a positive integer scalar". I am looking through the "Getting Started" section now.
I've been able to import the data and graph the plain data, it's the plot(diff line that is presenting the error.
What is the command you are using?
I originally graphed by using:
[num,txt,raw]=xlsread('Metal Data.xlsx') x = num(1:57,1); y = num(1:57,2); plot(x,y)
That gave me the base plow. I then tried to input the line that you gave me:
plot(diff(x,y));
but it gave me the aforementioned error.

Sign in to comment.

 Accepted Answer

plot(diff(y));
Please read the documentation to see how diff() works.
Please accept an answer when your problem has been solved.

2 Comments

Thank you so much for your help, my boss likes your answer!
My pleasure.
Tell your boss he can give me a job if he wants to... ;)

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Asked:

on 12 Jun 2014

Edited:

on 12 Jun 2014

Community Treasure Hunt

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

Start Hunting!