I am trying to call the function but it doesnt run. i have been trying to feed some input arguments but still there is something wrong wich i cant understand. I have uploaded the file here...anyone help? thanks

3 个评论

What is a sample line in which you run the code?
Note that you never read from the file whose name is passed in. You have coded
[~,~ , rawData ]= xlsread ( 'myfilename.xlsx' ,'','','basic ');
which always reads from the file whose name is exactly myfilename.xlsx
@walid: Please elaborate "still there is something wrong". Do you get an error message? Which input do you use?

请先登录,再进行评论。

 采纳的回答

walid mohammed
walid mohammed 2018-12-13

0 个投票

Dear Mr Roberson and Jan,
Thank you for your help. Now I have all the specific values for the required inputs how ever the function is called from another function which it attached with this answer. The problem is that every time I call it it gives this error: Expression or statement is incorrect--possibly unbalanced (, {, or [. could you advice, please. Thanks

1 个评论

Accepting an answer means, that the problem is solved and that no further help is needed. Is this the case?
Please do not let the readers guess which line is affected, because you have this important information already. I assume it is this line:
[~ ,~ ,~ ,~ ,~ , LR_POF ((j -1) * length ( filenames )+i ,:) ,Z((j -1)*length ( filenames )+i ,:) ,gamma ((j -1)* length ( filenames )+(i -1) *3+1:(j -1)* length ( filenames )+(i -1) *3+1+2 ,:) ,alpha ((j -1)* length (filenames )+(i -1) *3+1:(j -1)* length ( filenames )+(i -1) *3+1+2 ,:) ,beta((j -1)* length ( filenames )+(i -1) *3+1:(j -1)* length ( filenames )+(i -1)*3+1+2 ,:) ,delta ((j -1) * length ( filenames )+(i -1) *3+1:(j -1)* length (filenames )+(i -1) *3+1+2 ,:) ] = garchPrediction ( cell2mat ( filenames (i)),startDate , endDate ,N,T,dist , garchmodel ,q,lambda ,l);
This is extremely hard to read. I recommend to use the space characters in a clear and clean way. Then standard in Matlab is:
  • No space between a variable and the parenthesis for indexing
  • No space between a function and the parenthesis for the arguments
  • Spaces around operators, exception: The unary minus as in -1
  • Optional, but nice: Spaces behind a comma
Use the direct and efficient startDates{j} instead of the uglier indirection cell2mat ( startDates (j)).
k = (j - 1) * length(filenames) + i;
m1 = (j - 1) * length(filenames) + (i - 1) * 3 + 1;
m2 = m1 + 2;
[~, ~, ~, ~, ~, LR_POF(k ,:), Z(k, :), ...
gamma(m1:m2, :), alpha(m1:m2, :), beta(m1:m2, :), ...
delta(m1:m2, :)] = garchPrediction(filenames{i}, ...
startDate, endDate, N, T, dist, garchmodel, q, lambda, l);
This is not only easier to read, but does not confuse the interpreter also.
Your code would look much nicer, if you obtain length(filenames) once only - prefer numel because it is less prone to bugs:
nFiles = numel(filenames);

请先登录,再进行评论。

更多回答(1 个)

walid mohammed
walid mohammed 2018-12-5

0 个投票

Hi Jan,
the input i use are ( filename , startDate , endDate ,N,T,dist , modelname, q, lambda ,l) but still there is something wrong

2 个评论

We do not have your data files, and we do not have specific values for the variables you are calling with, so we cannot run the code to see the error message ourselves. You have also not shown the complete error message.
We will not be able to assist you further without further information.
@walid: Please post comments in the section for comments, not in the section for answers.
I cannot guess what "something wrong" means and in consequence I cannot suggest a solution. The names of the variables "filename , startDate , endDate ,N,T,dist , modelname, q, lambda ,l" do not matter, but the contents do. In addition we need to know, which problem you observe.

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Historical Contests 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by