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:
complex function combine

Subject: complex function combine

From: Yi

Date: 8 Mar, 2008 18:14:04

Message: 1 of 3

Supposing I have a very complex function, which have to use
several temporary variables to express. Like:

function=fun(x)
f1=x(1)*sin(x(2))+tanh(x(3))+x4^0.15
f2=sin(f1)+cos(x(2))+x(5)^7
f3=f1+f2*sin(x(8))
...
...
fn=f1+f2+...fn-1

f=fn^0.5

If I want to combine all these functions, what command I
can do?

If I want to save this a M.file and I want to use it in
another program, what I can do? Thanks!

Subject: complex function combine

From: Ashish Uthama

Date: 10 Mar, 2008 17:53:24

Message: 2 of 3

Are you looking for a 'function' in MATLAB (in programming terms)

     doc function

You can place all these commands logically in one file and have it execu=
te =

whenever you want the function value.

On Sat, 08 Mar 2008 13:14:04 -0500, Yi <hvachy@163.com> wrote:

> Supposing I have a very complex function, which have to use
> several temporary variables to express. Like:
>
> function=3Dfun(x)
> f1=3Dx(1)*sin(x(2))+tanh(x(3))+x4^0.15
> f2=3Dsin(f1)+cos(x(2))+x(5)^7
> f3=3Df1+f2*sin(x(8))
> ...
> ...
> fn=3Df1+f2+...fn-1
>
> f=3Dfn^0.5
>
> If I want to combine all these functions, what command I
> can do?
>
> If I want to save this a M.file and I want to use it in
> another program, what I can do? Thanks!

Subject: complex function combine

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 10 Mar, 2008 18:01:20

Message: 3 of 3

In article <fqul1c$d43$1@fred.mathworks.com>, Yi <hvachy@163.com> wrote:
>Supposing I have a very complex function, which have to use
>several temporary variables to express. Like:

>function=fun(x)
>f1=x(1)*sin(x(2))+tanh(x(3))+x4^0.15
>f2=sin(f1)+cos(x(2))+x(5)^7
>f3=f1+f2*sin(x(8))
>...
>...
>fn=f1+f2+...fn-1

>f=fn^0.5

>If I want to combine all these functions, what command I
>can do?

When you wrote f1=x(1)*sin(x(2))+tanh(x(3))+x4^0.15
did you mean f1=x(1)*sin(x(2))+tanh(x(3))+x(4)^0.15 ?

I am not clear from your posting (especially considering your
other postings) whether your f1, f2, and so on, would be -values-,
or would be -functions-. Your final result, f -- is that a -value-
or is it a complicated function ? For example, is each x(1), x(2)
and so on a numeric value, or are some (or all of them) themselves
symbols ?
--
  "Why does he stagger his mind with the mathematics of the sky?
  Once the question mark has arisen in the human brain the answer must
  be found, if it takes a hundred years. A thousand years."
                                              -- Walter Reisch

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