Clear Filters
Clear Filters

How do I get a 0 value time series data, given the range of another variable

4 views (last 30 days)
Hi
I am beginner to Matlab. I am using IRIS toolbox for economic modelling in matlab. I wanted to create a variable with 0 value, giving the time range of another variable. I have a code as follows:
d.shock_prem = tseries(get(d.le,'range'),0);
"shock_prem" is time series variable to be negerated with 0 value and "le" is the range variable for start and end of the time series. When I run the model, it get error and stuck in here since 3 days back. The error is :
Error using tseries (line 158)
[IrisToolbox] Error
*** Number of dates must match number of rows of observations when creating a new time series.
Error in makedata (line 69)
d.shock_prem = tseries(get(d.le,'range'),0);
Anyone to help me out.
Thanks

Answers (1)

Jaynik
Jaynik on 24 Jul 2024
Hi,
The error message indicates that the number of dates must match the number of rows of observations when creating a new time series. This means that the range obtained from d.le and the data to assign (which is a scalar 0 in above case) must have the same length.
In your case, get(d.le,'range') is likely returning a range of dates, while 0 is just a single value. To resolve this, you can create a vector of zeros that matches the length of your date range.
Here is the code for the same:
range = get(d.le,'range');
d.shock_prem = tseries(range, zeros(size(range)));
In this code, zeros(size(range)) creates a vector of zeros that has the same size as the date range. This should resolve the error. If you continue to encounter issues or if there are more specific aspects of your MATLAB code, please provide more details for better assistance.

Categories

Find more on Dates and Time in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!