Suppressing Function Console Output

조회 수: 15 (최근 30일)
Josh V
Josh V 2015년 9월 6일
댓글: Josh V 2015년 9월 7일
Im attempting to suppress the output of text to the console generated by a function. I'm aware this question has been asked several times in different formats, but unfortunately that hasn't resolved my issue.
First I will outline my code.
for i = 2:length(lreturns)
holder = garchvar(lreturns(1:i), 'GARCH', 'GAUSSIAN', 1, 1, 1, 1, 1, 0.05);
GARCH_Gaussian_VaR(i) = holder(1);
end
Each iteration of the function garchvar() generates a lower and upper number. My code creates a vector of these lower numbers and works fine for that purpose.
However, the function also generates a lot of unwanted output to the console - around 75 lines of text.
Things I have done to attempt to resolve this issue are:
Using evalc in the following way:
for i = 2:length(lreturns)
holder = evalc(garchvar(lreturns(1:i), 'GARCH', 'GAUSSIAN', 1, 1, 1, 1, 1, 0.05));
GARCH_Gaussian_VaR(i) = holder(1);
end
But this just gives the error message:
Undefined function 'evalc' for input arguments of type 'double'.
Ive tried to debug the function and comment or put semi-colons where output is generated. Embedded within garchvar is another function, and embedded within that function is another and so on. The first output is printed when I arrive at the following line of the function fmincon.m which is in the optimlib toolbox. When debugging step by step the first output is delivered after the line:
if diagnostics
% Do diagnostics on information so far
diagnose('fmincon',OUTPUT,flags.grad,flags.hess,flags.constr,flags.gradconst,...
XOUT,sizes.mNonlinEq,sizes.mNonlinIneq,lin_eq,lin_ineq,l,u,funfcn,confcn);
end
Even after Ive commented this section, this does not suppress the output. Hence I'm quite confused by this. If I continue to debug, the function does not provide the same output as if I run the function in normal mode.
So my question is how can I run my code and suppress all output to the console given that what I have tried hasn't worked.
Thanks

채택된 답변

Walter Roberson
Walter Roberson 2015년 9월 6일
holder = evalc('garchvar(lreturns(1:i), ''GARCH'', ''GAUSSIAN'', 1, 1, 1, 1, 1, 0.05)');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Conditional Variance Models에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by