Suppressing Function Console Output

6 次查看(过去 30 天)
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