MATLAB Answers

How to plot a second axis with vectors of different length?

8 views (last 30 days)
Fred on 30 Mar 2015
Answered: dpb on 30 Mar 2015
I want to create a plot with 3 time series. First DO with values starting from 1998 to 2012 and for secondary axis two other time series (lets call them F and D) which only have values for 1991, 2001, 2006 and 2011. It should look like this (I can do it in excel but not in Matlab):
I tried
function but it gave me error for not having same vector length. What can I do? Thanks


Sign in to comment.

Accepted Answer

dpb on 30 Mar 2015
You don't show what you tried specifically, but there's no problem with plotyy; you've got one array of some number of points and a second array of two variables with length four...
where t1,d1 are the data fro the D0 vector and d2 is a 4x2 array of the area/forest data at the times in t2. This uses the "classic" date number; if have newer release with the timeseries class there are alternate ways to get the time axis formatting...


Sign in to comment.

More Answers (0)

Sign in to answer this question.



Translated by