Simple Problem - Not enough input arguments
Show older comments
Ive used the following code frequently without problem, and suddenly encountered a problem. The code is as follows:
%%Compute daily returns
returns = diff(price);
%%compute daily log-returns
lreturns = diff(log(price));
%%Plot log returns
figure()
plot(date(2:end),lreturns)
title('Portfolio log-returns')
xlabel('Date')
ylabel('log-returns')
Fairly straight forward code. Calculate the returns, calculate the log of returns, plot the date against the log of returns. Always worked fine in the past, even worked yesterday on a shorter version of the data I'm using today (same format). However, today I am getting the error message:
Error using plot
Not enough input arguments.
Error in Log_Return (line 7)
plot(date(2:end),lreturns)
For some reason, if I do the following:
%%Compute daily returns
returns = diff(price);
%%compute daily log-returns
lreturns = diff(log(price));
%%Plot log returns
date1 = date(2:end);
figure()
plot(date(2:end),lreturns)
title('Portfolio log-returns')
xlabel('Date')
ylabel('log-returns')
Including the definition on line 6 of 'date1' it works fine.
Firstly I dont understand why it suddenly isn't working. Secondly, I dont see how including the definition of 'date1' has any impact on the plot since date1 isn't used in the plot.
Thanks
4 Comments
mashtine
on 26 Aug 2015
I think the problem may lie in fact that you are not defining date within you script and thus relying on it being in the workspace from previous runs. Thus if you modified date without you knowing, then the script will not work.
defining date1 = date(2:end) may better help matlab recognize that date is a variable and not a function trying to be used as you have no defined date previously.
Try with a more explicit definition and see. If that does not work, perhaps the data within date throws an error. Have you tried debug mode?
Walter Roberson
on 26 Aug 2015
is date(2:end) possibly empty or a scalar ?
Josh V
on 26 Aug 2015
mashtine
on 26 Aug 2015
Perhaps some formatting is carrying over. Weird indeed.
Answers (0)
Categories
Find more on Install Products 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!