Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB black hole variable

Tags:

syntax

matlab

Does MATLAB have a "blackhole" or discard variable?

Say I'm doing something like:

[ rows cols ] = size( A ) ;

But I don't want rows to be stored. Is there a "black hole" variable where I can send values to die?

So the assignment would be like

[ BLACKHOLE, cols ] = size( A ) ;

Where BLACKHOLE means throw the value away and don't create a variable for it.

like image 899
bobobobo Avatar asked Mar 23 '11 15:03

bobobobo


2 Answers

For 2009b or later, there is the tilde sign "~"

[~,cols] = size(A);

Alternatively, in your specific case

cols = size(A,2);
like image 186
Jonas Avatar answered Nov 25 '22 20:11

Jonas


For compatibility with Matlab versions prior to 2009b you can use the following technique

[cols, cols] = size(A);

See http://blogs.mathworks.com/steve/2010/01/11/about-the-unused-argument-syntax-in-r2009b/ for example

like image 38
Darren Rowland Avatar answered Nov 25 '22 20:11

Darren Rowland