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:
findobj gui

Subject: findobj gui

From: Nick

Date: 2 Dec, 2009 16:41:19

Message: 1 of 3

Ok so I'm having trouble finding an object I need.

Lets say I have 10 numbers :
case=(10,20,30,40,50,60,70,80,90,100);
and I randomize these numbers:
x=randperm(10);
case(x);

Also I have 10 static objects with
Tag names:
Static1, Static2, Static 3,........Static10;
and
Sting values:
$ 10, $ 20, $ 30,.......... $ 50;

Ok so question is say how do i findobj by using case(x)?
I was thinking this might work:
value1_h = findobj ('String',num2str(case(x))); <---------- but it doesnt work

I know it doesnt work because of the $ in the string and case(x) is just a number but i cannot change the string to not have the $.

How can I do this???

Subject: findobj gui

From: us

Date: 2 Dec, 2009 18:20:22

Message: 2 of 3

"Nick " <nichmoor@utm.edu> wrote in message <hf65bf$qq9$1@fred.mathworks.com>...
> Ok so I'm having trouble finding an object I need.
>
> Lets say I have 10 numbers :
> case=(10,20,30,40,50,60,70,80,90,100);
> and I randomize these numbers:
> x=randperm(10);
> case(x);
>
> Also I have 10 static objects with
> Tag names:
> Static1, Static2, Static 3,........Static10;
> and
> Sting values:
> $ 10, $ 20, $ 30,.......... $ 50;
>
> Ok so question is say how do i findobj by using case(x)?
> I was thinking this might work:
> value1_h = findobj ('String',num2str(case(x))); <---------- but it doesnt work
>
> I know it doesnt work because of the $ in the string and case(x) is just a number but i cannot change the string to not have the $.
>
> How can I do this???

one of the solutions
- use the more versatile SPRINTF function, eg

% note: do not create a var named CASE as this is part of the SWITCH block...
     s=sprintf('$ %d',nx);
     h=findobj('string',s);

us

Subject: findobj gui

From: Nick

Date: 3 Dec, 2009 03:49:02

Message: 3 of 3

"Nick " <nichmoor@utm.edu> wrote in message <hf65bf$qq9$1@fred.mathworks.com>...
> Ok so I'm having trouble finding an object I need.
>
> Lets say I have 10 numbers :
> case=(10,20,30,40,50,60,70,80,90,100);
> and I randomize these numbers:
> x=randperm(10);
> case(x);
>
> Also I have 10 static objects with
> Tag names:
> Static1, Static2, Static 3,........Static10;
> and
> Sting values:
> $ 10, $ 20, $ 30,.......... $ 50;
>
> Ok so question is say how do i findobj by using case(x)?
> I was thinking this might work:
> value1_h = findobj ('String',num2str(case(x))); <---------- but it doesnt work
>
> I know it doesnt work because of the $ in the string and case(x) is just a number but i cannot change the string to not have the $.
>
> How can I do this???

I figured out another way to do this.
just using
x=randperm(10)

temp=find(x)=1;
static=['Static',temp]
static_h=findobj('Tag','static')

and u just do the above for all values
then u can change anything you want

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