From: Alan B on
Is there any mechanism for controlling the display of large variables in the console? Say, by setting a maximum limit for numel(variable) that is allowed to get printed? I'm talking about just entering a variable name on the console with no semicolon, so adding a check in a custom printing function wouldn't solve this.

Once in a while I will accidentally have Matlab print out an array that's much larger than I thought it was (eg, 3000x3000). The version/installation of Matlab that I use also has a tendency to ignore ctrl-C signals when it is in the middle of something intensive, like a large fft, or a long printf operation. The combination of these means that sometimes I have to sit and watch millions of zeros stream down the console until Matlab decides to listen to the keyboard, or sometimes just wait until the print finishes. I would love to be able to get out of this situation when it occurs.
From: Doug Schwarz on
Alan B wrote:
> Is there any mechanism for controlling the display of large variables in
> the console? Say, by setting a maximum limit for numel(variable) that is
> allowed to get printed? I'm talking about just entering a variable name
> on the console with no semicolon, so adding a check in a custom printing
> function wouldn't solve this.

You can overload display. For example, put this function in a directory
called @double which is in a directory on your path (do not put @double
on your path):

function display(x)
if numel(x) > 200
disp('Too large to display.')
else
builtin('display',x)
end

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
From: Alan B on
Doug Schwarz <see(a)sig.for.address.edu> wrote in message <1fOnn.100298$Ye4.70412(a)newsfe11.iad>...
> Alan B wrote:
> > Is there any mechanism for controlling the display of large variables in
> > the console? Say, by setting a maximum limit for numel(variable) that is
> > allowed to get printed? I'm talking about just entering a variable name
> > on the console with no semicolon, so adding a check in a custom printing
> > function wouldn't solve this.
>
> You can overload display. For example, put this function in a directory
> called @double which is in a directory on your path (do not put @double
> on your path):
>
> function display(x)
> if numel(x) > 200
> disp('Too large to display.')
> else
> builtin('display',x)
> end
>
> --
> Doug Schwarz
> dmschwarz&ieee,org
> Make obvious changes to get real email address.

Thanks, Doug.

I missed this earlier because I thought I had added this to a watchlist, apparently I hadn't. I just wanted to add that, without a semicolon on the builtin('display',x); line, I get a recursion limit error. This is in R2006b, maybe it's not an issue for newer versions.