Got Questions? Get Answers.
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:
A simple question about displaying name of a Structure?

Subject: A simple question about displaying name of a Structure?

From: Virtualized

Date: 26 Jun, 2013 14:32:31

Message: 1 of 2

Hi Everyone

I want to display name of the Structure(S1 and S2 in my example). Right now i can access and display contents of Structure(S1 and S2) by using "getfield" function.

I have two files.
Name of first file which contains structure itself is "st".
Second file contains a small code to see contents of Structure(S1 and S2) and is named as "mf".

My desired output is to see names of Structures S1 and S2(alongwith what i am getting right now) but i can only see information about what structure contains:

S = 2x1 struct array with fields:
    val
    pal

Can you please just run this simple code(just type "st") and guide me what should i do to get names of Structures(S1 and S2) rather than information i am getting now.

Links to access two files are below:
http://www.2shared.com/file/LWUTww6K/mf_online.html
http://www.2shared.com/file/ltLm-hY-/st_online.html

Best Regards
 

Subject: A simple question about displaying name of a Structure?

From: Guru

Date: 3 Jul, 2013 09:08:09

Message: 2 of 2

Virtualized <razzaqadil@gmail.com> wrote in message <9965db06-44c4-45a6-9a17-7d084f043c0f@googlegroups.com>...
> Hi Everyone
>
> I want to display name of the Structure(S1 and S2 in my example). Right now i can access and display contents of Structure(S1 and S2) by using "getfield" function.
>
> I have two files.
> Name of first file which contains structure itself is "st".
> Second file contains a small code to see contents of Structure(S1 and S2) and is named as "mf".
>
> My desired output is to see names of Structures S1 and S2(alongwith what i am getting right now) but i can only see information about what structure contains:
>
> S = 2x1 struct array with fields:
> val
> pal
>
> Can you please just run this simple code(just type "st") and guide me what should i do to get names of Structures(S1 and S2) rather than information i am getting now.
>
> Links to access two files are below:
> http://www.2shared.com/file/LWUTww6K/mf_online.html
> http://www.2shared.com/file/ltLm-hY-/st_online.html
>
> Best Regards
>

Since you are passing the structures into your function mf, you can make use of the inputname function in MATLAB to obtain the name of the structure being passed in.

For instance, if you change line 13 in mf.m to:
inputname(1) you would see the corresponding structure being used for that instance instead.

On another note, you may want to avoid global variables in your function mf.m, especially if those same variables are being passed out as outputs of that function which makes it questionable why you are declaring them in the global workspace to begin with.

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