For Programmers: Free Programming Magazines  


Home > Archive > Matlab > February 2008 > Re: Is it possible to declare only one variable to a function that return several var









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Is it possible to declare only one variable to a function that return several var
Titus

2008-02-29, 8:35 am


"El Mariachi" <emilien.natter@gmail.com> schrieb im Newsbeitrag
news:51ecc6a3-b647-449e-bdce-0fad3f829611@47g2000hsb.googlegroups.com...
> For example:
>
> I have a function that returns 4 variables:
>
> [a,b,c,d] = my_function(arg_1)
>
> I just need the c variable, is there a syntaxe, without declaring a,b
> and d?
>
> Thanks!


Hi,
no, you can only get rid of the d:
[a,b,c] = my_function(arg_1);

Although: I think <us> once showed us the trick to
reuse the variable name, like in
[c,c,c] = my_function(arg_1);
but I'm not sure if this may confuse the reader more than
[unused1, unused2, c] = my_function(arg_1);

Titus


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com