Thread Subject: How to write a function?

Subject: How to write a function?

From: Sprinceana

Date: 10 Jun, 2009 17:33:01

Message: 1 of 7

Hi everyone!

I want to write the function identity: f(x)=x in matlab.

Can anyone help me please?

Subject: How to write a function?

From: Sprinceana

Date: 10 Jun, 2009 17:42:02

Message: 2 of 7

"Sprinceana " <mihaispr@yahoo.com> wrote in message <h0oqod$3te$1@fred.mathworks.com>...
> Hi everyone!
>
> I want to write the function identity: f(x)=x in matlab.
>
> Can anyone help me please?

example.m is my script

Code I wrote:

I want to implement f(x)=x in matlab.

function [y]=f(x)
%f(x)=x
y=x;

Is this ok?

Subject: How to write a function?

From: Sprinceana

Date: 10 Jun, 2009 17:58:01

Message: 3 of 7

"Sprinceana " <mihaispr@yahoo.com> wrote in message <h0or9a$9bs$1@fred.mathworks.com>...
> "Sprinceana " <mihaispr@yahoo.com> wrote in message <h0oqod$3te$1@fred.mathworks.com>...
> > Hi everyone!
> >
> > I want to write the function identity: f(x)=x in matlab.
> >
> > Can anyone help me please?
>
> example.m is my script
>
> Code I wrote:
>
> I want to implement f(x)=x in matlab.
>
> function [y]=f(x)
> %f(x)=x
> y=x;
>
> Is this ok?

Name is f.m sry:(

Subject: How to write a function?

From: Sprinceana

Date: 10 Jun, 2009 18:39:02

Message: 4 of 7

"Sprinceana " <mihaispr@yahoo.com> wrote in message <h0os79$bg9$1@fred.mathworks.com>...
> "Sprinceana " <mihaispr@yahoo.com> wrote in message <h0or9a$9bs$1@fred.mathworks.com>...
> > "Sprinceana " <mihaispr@yahoo.com> wrote in message <h0oqod$3te$1@fred.mathworks.com>...
> > > Hi everyone!
> > >
> > > I want to write the function identity: f(x)=x in matlab.
> > >
> > > Can anyone help me please?
> >
> > example.m is my script
> >
> > Code I wrote:
> >
> > I want to implement f(x)=x in matlab.
> >
> > function [y]=f(x)
> > %f(x)=x
> > y=x;

I defined well my function I hope.

Wait for an answer pls!


> >
> > Is this ok?
>
> Name is f.m sry:(

Subject: How to write a function?

From: Ulf Graewe

Date: 10 Jun, 2009 18:59:03

Message: 5 of 7

type "doc function" in the command line, a you will find help!

Subject: How to write a function?

From: Lucas

Date: 10 Jun, 2009 20:05:05

Message: 6 of 7

function x = f(x)

should work and is fairly minimal, and (optimally) fast too

Subject: How to write a function?

From: Sprinceana

Date: 10 Jun, 2009 21:51:02

Message: 7 of 7

"Lucas " <l.antispamchars.wilkins@sussex.moreantispam.ac.unitedkingdomdomainname> wrote in message <h0p3lg$2n9$1@fred.mathworks.com>...
> function x = f(x)
>
> should work and is fairly minimal, and (optimally) fast too

Ok. Thanks! So I made correct I want to verify that!

Thanks again lucas!

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
define a simple... Sprinceana 10 Jun, 2009 17:54:12
identity function Sprinceana 10 Jun, 2009 13:44:05
function fxx id... Sprinceana 10 Jun, 2009 13:34:05
rssFeed for this Thread

Contact us at files@mathworks.com