Undefined function or variable
    4 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    economics student
 am 24 Jan. 2021
  
    
    
    
    
    Kommentiert: economics student
 am 30 Jan. 2021
            Undefined function or variable 'Date2Num'. I am not sure whether this is due to a mix in coding from Python where Date2Num is used to convert date time objects to Matplotlib dates. What is the corresponding function in Matlab? Thanks in advance.
Error in VARToolbox_Primer (line 15)
datesnum = Date2Num(dates);
7 Kommentare
  dpb
      
      
 am 24 Jan. 2021
				Date2Num is not builtin MATLAB function so looks like you're missing an m-file that went with the code you do have or if it is an attempt to use a Python function I believe you have to import it somehow--I've never done that so don't know the specifics.
Akzeptierte Antwort
  dpb
      
      
 am 24 Jan. 2021
        
      Bearbeitet: dpb
      
      
 am 24 Jan. 2021
  
      As noted above I don't know for certain whether the Date2Num is just a missing m-file or an attempt to use a Python function.
You don't need it though, and converting to use the new(ish) table object is probably worth the effort.  It takes only a little bit of help for readtable and you have all the data in one table instead of text and numerics separate as with the deprecated xlsread route.
optMACRO=detectImportOptions('MACRO_US.xlsx','Sheet','Sheet1','NumHeaderLines',1);
tMACRO=readtable('MACRO_US.xlsx',optMACRO);
tMACRO.t=datetime(tMACRO.t,'InputFormat','yyyyQ','Format','yyyy''q''Q');
the result for the attached file is
>> head(tMACRO)
ans =
  8×7 table
      t        cpi       gdp     unemp      vix     i1yr       ebp   
    ______    ______    _____    ______    _____    ____    _________
    1989q1    51.333     52.3       5.2    17.82    9.29       0.4049
    1989q2    52.162     52.7    5.2333    17.02    8.93       0.5758
    1989q3     52.57    53.09    5.2333    18.08     8.1       0.7444
    1989q4    53.105    53.19    5.3667    20.35    7.83       0.5925
    1990q1    54.019    53.77       5.3    21.75    8.13      0.38887
    1990q2    54.553    53.97    5.3333    18.68    8.27      0.14737
    1990q3    55.495       54       5.7    25.08    7.83    -0.031533
    1990q4    56.438    53.51    6.1333    25.99     7.3       0.2838
>> 
10 Kommentare
  Walter Roberson
      
      
 am 27 Jan. 2021
				I recommend using pathtool as it gives a nice visual interface. 
With pathtool items that are higher up in the list have priority over items lower down in the list.
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Dates and Time 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!


