Find the rate of change of data over specific increments of time
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Lukyan
am 27 Okt. 2022
Beantwortet: David Hill
am 27 Okt. 2022
I am working on a project where I need to analyze stock data. I decided to create a graph of the change of stock prices over time. I want the graph to be the rate of change of tesla close prices over one month time intervals. However, I am having trouble creating the rate of change vector as I do not know how to make the intervals work. My data is day by day but I want the vector to be the difference from the currMonth to currMonth-1. I don't have much so far, but if I only had the rate of change vector, plotting everything else would be simple. Basically, I want to graph the first derivative of the close prices in one month increments and display that data of a 10 year range.
Thank you so much.
clear
clc
clf
%import data set TSLA.csv
data = readtable("TSLA_STOCK.csv");
%get vector of tesla close prices
closePrices = data.Close;
%Convert dates into durations
data.MONTH = month(data.Date);
%rate_of_change_of_close_price = diff(closePrices)./diff(data.MONTH)
% create plot with axis labels, title, and grid
%plot(tslaStock.Date, rate_of_change_of_close_price, "-")
%xlim([datetime(2012,11,24,8,40,59)...
% datetime(2019,4,19,16,40,59)])
%ylim([3 536])
%xlabel('Year')
%ylabel('TSLA Price')
%title('TSLA price per share vs Time')
%grid on
3 Kommentare
Akzeptierte Antwort
David Hill
am 27 Okt. 2022
data = readtable('TSLA_STOCK.csv');
idx=find(diff(month(data.Date)));
monthlyClose=data.Close(idx);
ROV=diff(monthlyClose)./monthlyClose(1:end-1)*100;
plot(ROV)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Financial Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
