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

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com