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:
How to change value of field in a array of structures

Subject: How to change value of field in a array of structures

From: Henry

Date: 18 Apr, 2009 19:18:21

Message: 1 of 5

Is there a quicker way to do this?

for iStruct = 1:length(myStruct)
  myStruct(iStruct).field = 'New Value';
end

Subject: How to change value of field in a array of structures

From: Bruno Luong

Date: 18 Apr, 2009 19:33:01

Message: 2 of 5

Henry <zemp@itp.unibe.ch> wrote in message <d561906c-62a3-4884-93c8-07721039c078@k8g2000yqn.googlegroups.com>...
> Is there a quicker way to do this?
>
> for iStruct = 1:length(myStruct)
> myStruct(iStruct).field = 'New Value';
> end

[myStruct(iStruct).field] = deal('New Value')

Bruno

Subject: How to change value of field in a array of structures

From: Jiro Doke

Date: 18 Apr, 2009 19:59:02

Message: 3 of 5

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <gsd9td$g4b$1@fred.mathworks.com>...
> Henry <zemp@itp.unibe.ch> wrote in message <d561906c-62a3-4884-93c8-07721039c078@k8g2000yqn.googlegroups.com>...
> > Is there a quicker way to do this?
> >
> > for iStruct = 1:length(myStruct)
> > myStruct(iStruct).field = 'New Value';
> > end
>
> [myStruct(iStruct).field] = deal('New Value')
>
> Bruno

I think you meant

[myStruct.field] = deal('New Value')



jiro

Subject: How to change value of field in a array of structures

From: Bruno Luong

Date: 18 Apr, 2009 20:03:01

Message: 4 of 5

"Jiro Doke" <jiro.doke@mathworks.com> wrote in message <gsdbe6$o0n$1@fred.mathworks.com>...


>
> I think you meant
>
> [myStruct.field] = deal('New Value')

Yes. Thanks for the correction! ;-)

Bruno

Subject: How to change value of field in a array of structures

From: Henry

Date: 18 Apr, 2009 20:54:59

Message: 5 of 5

Hi Bruno, Hi Jiro

Thank you very much. I thought there must be some easy way to do this.

With best regards

Henry

Tags for this Thread

No tags are associated with 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