Sliding Window x-axis - matlab

I already do sliding window in order to calculate some parameters of networks. In this case, I'm working with a financial network based in daily returns of 140 companies.
I already have all my calculations, but when I plot my results I obtain the number of sliding movements ("Sliding Steps") in my x-axis, but instead of steps I need years in my x-axis.
In order to change the values of x-axis, I applied the same procedure ("sliding window") but in this case, only for a vector of years and then I calculated the "mode" of each "window" I obtain a 1124 x 1 array that contains the years of each window. How i can change those "steps" by "years" in the array?

You are looking for the axis-properties XTick and XTickLabel of Matlab plots. The documentation by Mathworks provides a useful example at http://www.mathworks.de/de/help/matlab/creating_plots/setting-axis-parameters.html#f6-29060
Instead of the values in the interval of -pi/2 to pi/2 you want to place the years.

Related

question regarding facebook prophet, is there a way to identify points on the plot?

enter image description here
my data is similar to this i.e. years on x-axis and values on y-axis, I think prophet requires the x-axis to have "ds" and the y-axis as "y" to work but is there a way to use identify() to determine particular points on the plot?

Area under surface between two curves [duplicate]

This question already has an answer here:
Area between line and curve (no function)
(1 answer)
Closed 6 years ago.
I want to determine the area between the red line and the blue line but only to the y-value of 4.559. How can I achieve that?
In general:
First you have to subtract the two functions from each other. After
that, you have a function that represents the delta in y for each
point on the x-axis.
After that you have to calculate the integral, for matlab you should look here Matlab - Numerical Integral
The last step is inserting the left, and the right bound of your desired area to calculate. The result is the area under the surface
Be careful when subtracting the functions, the result of the area might be negative (negate it in this case) if the "bigger" function is the subtrahend

Adding date tick marks to a Matlab plot

I have a plot of time series data, and I would like to replace the tick marks of the x-axis (automatically I have the number of the ordered observations) with the date when the value is observed. I would like to have a tick mark every 5 years for example. I know how to do it with R, but with MATLAB seems so complicated and I'm not getting the result I want.
There is an answer on the Mathworks website that I think you will find helpful: http://www.mathworks.com/matlabcentral/answers/92565-how-do-i-control-axis-tick-labels-limits-and-axes-tick-locations. Basically what you want to do is manipulate the XTick or XTickLabel attributes of the current axis handle. Lets say I have a plot that spans 100 years from 1900 - 2000. After creating the plot, I can set year labels in 5 year increments by doing:
set(gca, 'XTick', 1900:5:2000);

How to plot different data in parallel (in continuation of the previous one)

I have some energy 24 hour consumption data of many days.
Plotting a specific day gives me vertical axis of consumption and horizontal axis of time.
I would like to plot for lets say 1 year.
If I use "hold on/off" command, it plots all days together on top of each other.
How can i plot in a way that for the second day, the plots goes to the continue of the first plot (horizontal axis extends automatically)? So, when I have the complete plot, it shows 365 days of energy consumption based on hour. It's like the horizontal axis is repeating while the vertical axis is updating. I'm talking about MATLAB.
You can still use hold on and plot each day separately (if I understand your question properly, this is what you want, separate plotting). Simply make sure your x-axis values are correct. So e.g. if you have one measurement value per hour, the plot day 1:
plot(1:24,valDay1,'k-')
then for day 2:
plot(25:48,valDay2,'r-')
etc. This will line things up correctly. Also, consider using a datetime as x axis values
So, I found my solution which is very simple. I don't know how it didn't occur earlier.
I just had to use ";" and that's it.
Like this:
DAY=[day1;day2;day3]
plot(DAY)

Two left Y axis [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Plotting 4 curves in a single plot, with 3 y-axes
Dear stackoverflowers,
I need to plot 3 curves with same X axis (time) but three different dimensions (Volt, temp, current). The best outlook, to me, would be to have two Y axis on the left side, separated by a few pixel so we can read legend and ticks for each.
The answer to my questions are not plotyy neither multiple X or Y axis . In the first case, it helps me plot two different dimensions, not three.
the latter helps me associate right or left Y axis to a particular curve. I used the YAxisLocation option for my third curve but if I put it right or left, of course it interfers with the other YAxis that was there before. There is no option like left - 20 pixels ?
Thank you for your help.
You could just use plot (which will take care of the scale) and then include a legend to say what your units are (e.g. volts, degrees, etc)