~ a cool new feature in Matlab

18 01 2010

I just noticed this recently. In Matlab, you can now say [~, b] = somefunction(input);
What that basically does is that it tells the function that whatever is the first argument that it returns, the caller is not interested in it at all… So, you dont need to use those temporary or waste variables now. A similar thing applies to inputs/parameters to a function too… check it out.

Advertisements

Actions

Information

3 responses

19 01 2010
Scott Hirsch

Thanks for the feedback on this new feature. I love how simple and elegant it is.

Just curious – how did you discover this feature? I’m always trying to figure out how to best help users learn about the new things in MATLAB that they may find useful.

19 01 2010
ohilthegreat

I guess I found it in quite a few places… but the first time was when I looked up the new features in R2009B. Other than that, there is this blog “Steve’s Image Processing Blog” that I subscribe to. The ~ feature was highlighted there too. I must say – Great Work!

20 01 2010
ohilthegreat

I just remembered… I first used this when Matlab auto-suggested replacing a variable I wasnt using with the ~… it even game me a button “Fix” 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: