Thread Subject: Functions as variable Names

Subject: Functions as variable Names

From: Alex

Date: 7 Feb, 2012 17:48:09

Message: 1 of 2

Dear all I would like to map functions to variable names.....
I will try to explain you what I want to do so we can discuss if it makes sense what I am trying to.


Lets say that I have the following 4 functions
function name: Psi_h returns the H matrices from 1 to i (there is a function that gives the H)
function name: Psi_g returns the G and the H matrices from 1 to i-1 (function also returns G)


then I want to calculate the

Psi_h_h which will be the Psi_h (Kronecker Product) Psi_h
Psi_h_g which will be the Psi_h (Kronecker Product) Psi_g
Psi_g_h which will be the Psi_g (Kronecker Product) Psi_h
Psi_g_g which will be the Psi_g (Kronecker Product) Psi_g


then I want to calculate the

Psi_h_h_h

...and so on....
is it possible to write then only the psi_h function ones and then have an easy way for calling those many times as needed?

Regards
Alex

Subject: Functions as variable Names

From: TideMan

Date: 7 Feb, 2012 19:10:02

Message: 2 of 2

On Feb 8, 6:48 am, "Alex " <ala...@yahoo.com> wrote:
> Dear all I would like to map functions to variable names.....
> I will try to explain you what I want to do so we can discuss if it makes sense what I am trying to.
>
> Lets say that I have the following 4 functions
> function name: Psi_h  returns the H matrices from 1 to i (there is a function that gives the H)
> function name: Psi_g returns the G and the H matrices from 1 to i-1 (function also returns G)
>
> then I want to calculate the
>
> Psi_h_h which will be the Psi_h (Kronecker Product) Psi_h
> Psi_h_g which will be the Psi_h (Kronecker Product) Psi_g
> Psi_g_h which will be the Psi_g (Kronecker Product) Psi_h
> Psi_g_g which will be the Psi_g (Kronecker Product) Psi_g
>
> then I want to calculate the
>
> Psi_h_h_h
>
> ...and so on....
> is it possible to write then only the psi_h function ones and then have an easy way for calling those many times as needed?
>
> Regards
> Alex

Yes, of course, but not with silly names like Psi_g_h.
Use a matrix instead, after all that is what Matlab stands for: Matrix
Laboratory
Psi=zeros(2,2);
Psi(1,1) will be Psi_h_h
Psi(1,2) will be Psi_h_g
and so on

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

Contact us at files@mathworks.com