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

Walter Roberson
Walter Roberson 2018년 12월 5일
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 2018년 12월 5일
@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

Jan
Jan 2018년 12월 13일
편집: Jan 2018년 12월 13일
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

Walter Roberson
Walter Roberson 2018년 12월 5일
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 2018년 12월 6일
@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에 대해 자세히 알아보기

질문:

2018년 12월 5일

편집:

Jan
2018년 12월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by