Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Aim I having a senior moment or what...???

Subject: Aim I having a senior moment or what...???

From: dpb

Date: 24 Apr, 2013 00:25:08

Message: 1 of 7

DEAL() duplicates all terms in the RHS, is there a shorthand for

A=x(1);
B=x(2);

[A B]=???(x);

Am I just drawing a blank or is there only the explicit assignment
statements? Seems trivial and after 30 yr...

--

Subject: Aim I having a senior moment or what...???

From: Doug Schwarz

Date: 24 Apr, 2013 01:22:21

Message: 2 of 7

In article <kl78pg$llb$1@speranza.aioe.org>, dpb <none@non.net> wrote:

> DEAL() duplicates all terms in the RHS, is there a shorthand for
>
> A=x(1);
> B=x(2);
>
> [A B]=???(x);
>
> Am I just drawing a blank or is there only the explicit assignment
> statements? Seems trivial and after 30 yr...


I can't think of a built-in way to do it, but the function is only two
lines:

-------------------------------
function varargout = dealvec(x)
varargout = num2cell(x);
-------------------------------


[A,B] = dealvec(x);

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.

Subject: Aim I having a senior moment or what...???

From: dpb

Date: 24 Apr, 2013 05:38:35

Message: 3 of 7

On 4/23/2013 8:22 PM, Doug Schwarz wrote:
> In article<kl78pg$llb$1@speranza.aioe.org>, dpb<none@non.net> wrote:
>
>> DEAL() duplicates all terms in the RHS, is there a shorthand for
>>
>> A=x(1);
>> B=x(2);
>>
>> [A B]=???(x);
>>
>> Am I just drawing a blank or is there only the explicit assignment
>> statements? Seems trivial and after 30 yr...
>
>
> I can't think of a built-in way to do it, but the function is only two
> lines:
>
> -------------------------------
> function varargout = dealvec(x)
> varargout = num2cell(x);
> -------------------------------
>
>
> [A,B] = dealvec(x);

OK, thanks, Doug...

Idiom just came up in an offline conversation where was convenient to
have the named variables and got me puzzling over it...whether I was
forgetting something.

--

Subject: Aim I having a senior moment or what...???

From: Eric Sampson

Date: 24 Apr, 2013 18:05:08

Message: 4 of 7

dpb <none@non.net> wrote in message <kl7r55$qi2$1@speranza.aioe.org>...
> On 4/23/2013 8:22 PM, Doug Schwarz wrote:
> > In article<kl78pg$llb$1@speranza.aioe.org>, dpb<none@non.net> wrote:
> >
> >> DEAL() duplicates all terms in the RHS, is there a shorthand for
> >>
> >> A=x(1);
> >> B=x(2);
> >>
> >> [A B]=???(x);
> >>
(snip)
>

I recently sent an enhancement request in to TMW to create a new function/syntax to create a comma-separated list from a regular array, which seems like what you're looking for here? If so, please call/email TMW support and let them know to add your vote to this enhancement request - they weren't sure of this construct's usefulness at first when I suggested it, so having users contact them to vote for this enhancement request would help :)

Subject: Aim I having a senior moment or what...???

From: Bruno Luong

Date: 24 Apr, 2013 19:32:11

Message: 5 of 7

"Eric Sampson" wrote in message <kl96sk$lg1$1@newscl01ah.mathworks.com>...

>
> I recently sent an enhancement request in to TMW to create a new function/syntax to create a comma-separated list from a regular array,

There is a more generic request that cover this: cascading reference operators.

num2cell(a){:}

Should do the trick.

But TMW can put forward 36 reasons why they don't want to do that.

Bruno

Subject: Aim I having a senior moment or what...???

From: james bejon

Date: 24 Apr, 2013 20:27:07

Message: 6 of 7

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <kl9bvr$8o3$1@newscl01ah.mathworks.com>...
> "Eric Sampson" wrote in message <kl96sk$lg1$1@newscl01ah.mathworks.com>...
>
> >
> > I recently sent an enhancement request in to TMW to create a new function/syntax to create a comma-separated list from a regular array,
>
> There is a more generic request that cover this: cascading reference operators.
>
> num2cell(a){:}
>
> Should do the trick.
>
> But TMW can put forward 36 reasons why they don't want to do that.
>
> Bruno

Pity--works fine in Octave...

Subject: Aim I having a senior moment or what...???

From: dpb

Date: 25 Apr, 2013 01:38:34

Message: 7 of 7

On 4/24/2013 3:27 PM, james bejon wrote:
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message
> <kl9bvr$8o3$1@newscl01ah.mathworks.com>...
>> "Eric Sampson" wrote in message
>> <kl96sk$lg1$1@newscl01ah.mathworks.com>...
>>
>> > > I recently sent an enhancement request in to TMW to create a new
>> function/syntax to create a comma-separated list from a regular array,
>> There is a more generic request that cover this: cascading reference
>> operators.
>>
>> num2cell(a){:}
>>
>> Should do the trick.
>>
>> But TMW can put forward 36 reasons why they don't want to do that.
>>
>> Bruno
>
> Pity--works fine in Octave...

Indeed...in the same application came across similar limitation in
accessing structure elements across array that required a loop construct
for any way I could come up to get the necessary results. My
introduction to the full feature set of ML is of such recent vintage
that I'm not yet convinced it's not possible; I'm in the process of
trying to construct a suitably simple example case that illustrates the
issue to post...

Mayhap can reference the thread in bumping up the response count to the
enhancement requests? I'm not sure how to actually get something to TMW
directed towards a given enhancement as I rarely use their portal/site...

--

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us