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:
Applying function to ;atrix elements

Subject: Applying function to ;atrix elements

From: Salah Eddine

Date: 5 Apr, 2011 17:59:22

Message: 1 of 4

Hi.
I'm working on a program and I need to create a function of variable x and apply this function to each element of a matrix without using a for loop, how can this be done?
I need your help please

Subject: Applying function to ;atrix elements

From: Florin Neacsu

Date: 5 Apr, 2011 18:10:08

Message: 2 of 4

"Salah Eddine " <salaheddine.saidi@gmail.com> wrote in message <infl9p$m7n$1@fred.mathworks.com>...
> Hi.
> I'm working on a program and I need to create a function of variable x and apply this function to each element of a matrix without using a for loop, how can this be done?
> I need your help please

Hi,

Have a look at bsxfun. It might help you.
>doc bsxfun

Regards,
Florin

Subject: Applying function to ;atrix elements

From: Wayne King

Date: 5 Apr, 2011 18:12:05

Message: 3 of 4

"Salah Eddine " <salaheddine.saidi@gmail.com> wrote in message <infl9p$m7n$1@fred.mathworks.com>...
> Hi.
> I'm working on a program and I need to create a function of variable x and apply this function to each element of a matrix without using a for loop, how can this be done?
> I need your help please

Hi, Read the help for arrayfun()

Wayne

Subject: Applying function to ;atrix elements

From: Salah Eddine

Date: 5 Apr, 2011 18:49:20

Message: 4 of 4

"Wayne King" <wmkingty@gmail.com> wrote in message <infm1l$63s$1@fred.mathworks.com>...
> "Salah Eddine " <salaheddine.saidi@gmail.com> wrote in message <infl9p$m7n$1@fred.mathworks.com>...
> > Hi.
> > I'm working on a program and I need to create a function of variable x and apply this function to each element of a matrix without using a for loop, how can this be done?
> > I need your help please
>
> Hi, Read the help for arrayfun()
>
> Wayne

Thank you very much, it was really helpful, exactly what i looked for

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