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 commentaires

Walter Roberson
Walter Roberson le 5 Déc 2018
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
Jan
Jan le 5 Déc 2018
@walid: Please elaborate "still there is something wrong". Do you get an error message? Which input do you use?

Connectez-vous pour commenter.

 Réponse acceptée

walid mohammed
walid mohammed le 13 Déc 2018

0 votes

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 commentaire

Jan
Jan le 13 Déc 2018
Modifié(e) : Jan le 13 Déc 2018
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);

Connectez-vous pour commenter.

Plus de réponses (1)

walid mohammed
walid mohammed le 5 Déc 2018

0 votes

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

2 commentaires

Walter Roberson
Walter Roberson le 5 Déc 2018
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.
Jan
Jan le 6 Déc 2018
@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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Historical Contests dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by