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:
Matlab GUI: displaying a Transfer Function in a static text box

Subject: Matlab GUI: displaying a Transfer Function in a static text box

From: RobuLAB

Date: 17 May, 2010 09:31:03

Message: 1 of 10

I want to display a tranfer function in a static text box.
In my first attempt I coded everything and that worked fine but is sometimes difficult to read because everything is displayed, even the values that are zero.
I now would like to use the tf-command.
I wrote something like this to test:

text=tf([1 1 1 1 1],[2 2 2 2 2 2 2]);
set(handles.text1,'Value',text);

but that doesn't work. I changed 'Value' to 'string' but that also doesn't work.
anyone has any ideas?

thanks in Advance

Subject: Matlab GUI: displaying a Transfer Function in a static text box

From: Steven Lord

Date: 17 May, 2010 13:33:38

Message: 2 of 10


"RobuLAB " <amaury.ampe@etu.u-bordeaux1.fr> wrote in message
news:hsr2cn$4mf$1@fred.mathworks.com...
>I want to display a tranfer function in a static text box.
> In my first attempt I coded everything and that worked fine but is
> sometimes difficult to read because everything is displayed, even the
> values that are zero.
> I now would like to use the tf-command.
> I wrote something like this to test:
>
> text=tf([1 1 1 1 1],[2 2 2 2 2 2 2]);
> set(handles.text1,'Value',text);
>
> but that doesn't work. I changed 'Value' to 'string' but that also doesn't
> work.
> anyone has any ideas?
>
> thanks in Advance

Use EVALC to capture the display of the transfer function, and set the
String property of that text box to contain EVALC's output.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Matlab GUI: displaying a Transfer Function in a static text box

From: RobuLAB

Date: 17 May, 2010 15:05:05

Message: 3 of 10

"Steven Lord" <slord@mathworks.com> wrote in message

> Use EVALC to capture the display of the transfer function, and set the
> String property of that text box to contain EVALC's output.
>

Thanks a lot! I'm glad to know that it's possible. However with my limited Matlab skills I don't seem to get it right.

So I tried:
k=tf([1 1 1 1 1],[2 2 2 2 2 2 2]);
T=EVALC(k);
set(handles.text1,'String',T);
but that doesn't work.
When I tried it in the command window without the set-instruction it just gave me error saying: ??? Undefined function or method 'EVALC' for input arguments of type 'tf'.
I'm thinking it has something to do with capturing the "display" of the transfer function and not the thing itself. But I don't really know what you mean by that.

Could you please elaborate and tell me what I'm doing wrong?

Subject: Matlab GUI: displaying a Transfer Function in a static text box

From: Craig Buhr

Date: 18 May, 2010 15:23:31

Message: 4 of 10

The input arguement to evalc should be the string that is to be evaluated.
Try

> k=tf([1 1 1 1 1],[2 2 2 2 2 2 2]);
> T=evalc('k');

T will be the string which is the display of the variable k

Hope that helps.
-craig



"RobuLAB " <amaury.ampe@etu.u-bordeaux1.fr> wrote in message
news:hsrlv1$pkp$1@fred.mathworks.com...
> "Steven Lord" <slord@mathworks.com> wrote in message
>> Use EVALC to capture the display of the transfer function, and set the
>> String property of that text box to contain EVALC's output.
>>
>
> Thanks a lot! I'm glad to know that it's possible. However with my limited
> Matlab skills I don't seem to get it right.
> So I tried: k=tf([1 1 1 1 1],[2 2 2 2 2 2 2]);
> T=EVALC(k);
> set(handles.text1,'String',T);
> but that doesn't work. When I tried it in the command window without the
> set-instruction it just gave me error saying: ??? Undefined function or
> method 'EVALC' for input arguments of type 'tf'.
> I'm thinking it has something to do with capturing the "display" of the
> transfer function and not the thing itself. But I don't really know what
> you mean by that.
>
> Could you please elaborate and tell me what I'm doing wrong?
>

Subject: Matlab GUI: displaying a Transfer Function in a static text box

From: RobuLAB

Date: 19 May, 2010 09:50:04

Message: 5 of 10

Unfortunately it doesn't work that way. But I now realise that the problem is that I need a string to be able to display something. A bit of googling on "tf to string" gave me some solutions. There's apparently no simple way of doing it. You have to break up the tf and convert each part separatly, but it works.

Thx for your help


"Craig Buhr" <cbuhr@mathworks.com> wrote in message <hsubdm$84r$1@fred.mathworks.com>...
> The input arguement to evalc should be the string that is to be evaluated.
> Try
>
> > k=tf([1 1 1 1 1],[2 2 2 2 2 2 2]);
> > T=evalc('k');
>
> T will be the string which is the display of the variable k
>
> Hope that helps.
> -craig
>
>
>
> "RobuLAB " <amaury.ampe@etu.u-bordeaux1.fr> wrote in message
> news:hsrlv1$pkp$1@fred.mathworks.com...
> > "Steven Lord" <slord@mathworks.com> wrote in message
> >> Use EVALC to capture the display of the transfer function, and set the
> >> String property of that text box to contain EVALC's output.
> >>
> >
> > Thanks a lot! I'm glad to know that it's possible. However with my limited
> > Matlab skills I don't seem to get it right.
> > So I tried: k=tf([1 1 1 1 1],[2 2 2 2 2 2 2]);
> > T=EVALC(k);
> > set(handles.text1,'String',T);
> > but that doesn't work. When I tried it in the command window without the
> > set-instruction it just gave me error saying: ??? Undefined function or
> > method 'EVALC' for input arguments of type 'tf'.
> > I'm thinking it has something to do with capturing the "display" of the
> > transfer function and not the thing itself. But I don't really know what
> > you mean by that.
> >
> > Could you please elaborate and tell me what I'm doing wrong?
> >
>
>

Subject: Matlab GUI: displaying a Transfer Function in a static text box

From: RICARDO SANCHEZ

Date: 24 May, 2010 18:46:04

Message: 6 of 10

"RobuLAB " <amaury.ampe@etu.u-bordeaux1.fr> wrote in message <ht0c8c$ne9$1@fred.mathworks.com>...
> Unfortunately it doesn't work that way. But I now realise that the problem is that I need a string to be able to display something. A bit of googling on "tf to string" gave me some solutions. There's apparently no simple way of doing it. You have to break up the tf and convert each part separatly, but it works.
>
> Thx for your help
>
>
> "Craig Buhr" <cbuhr@mathworks.com> wrote in message <hsubdm$84r$1@fred.mathworks.com>...
> > The input arguement to evalc should be the string that is to be evaluated.
> > Try
> >
> > > k=tf([1 1 1 1 1],[2 2 2 2 2 2 2]);
> > > T=evalc('k');
> >
> > T will be the string which is the display of the variable k
> >
> > Hope that helps.
> > -craig
> >
> >
> >
> > "RobuLAB " <amaury.ampe@etu.u-bordeaux1.fr> wrote in message
> > news:hsrlv1$pkp$1@fred.mathworks.com...
> > > "Steven Lord" <slord@mathworks.com> wrote in message
> > >> Use EVALC to capture the display of the transfer function, and set the
> > >> String property of that text box to contain EVALC's output.
> > >>
> > >
> > > Thanks a lot! I'm glad to know that it's possible. However with my limited
> > > Matlab skills I don't seem to get it right.
> > > So I tried: k=tf([1 1 1 1 1],[2 2 2 2 2 2 2]);
> > > T=EVALC(k);
> > > set(handles.text1,'String',T);
> > > but that doesn't work. When I tried it in the command window without the
> > > set-instruction it just gave me error saying: ??? Undefined function or
> > > method 'EVALC' for input arguments of type 'tf'.
> > > I'm thinking it has something to do with capturing the "display" of the
> > > transfer function and not the thing itself. But I don't really know what
> > > you mean by that.
> > >
> > > Could you please elaborate and tell me what I'm doing wrong?
> > >
> >
> > *************************
It really work...thanks guys
num=[R];
den=[1 2];
sys=tf(num,den)
T=evalc('sys');
set(handles.text1,'String',T);
*******************************

Subject: Matlab GUI: displaying a Transfer Function in a static text box

From: RobuLAB

Date: 25 May, 2010 14:17:04

Message: 7 of 10

"RICARDO SANCHEZ" <ricardo_adriano@hotmail.com> wrote in message <htehhc$m2f$1@fred.mathworks.com>...

> > > *************************
> It really work...thanks guys
> num=[R];
> den=[1 2];
> sys=tf(num,den)
> T=evalc('sys');
> set(handles.text1,'String',T);
> *******************************

I'm sorry, I don't know what I did wrong last time but it really does work now. I probably should do a little more trying before I state that something doesn't work.
Anyway I'm not going to use it since I found a way that gives me a little more control over what's printed and how.
e.g.:
My assignment is to specifically have 8 decimal digits so I adapted some code to be able to show all of those digits.
Since I'm using discrete-time transfer functions I have my sampling time printed when using evalc. I don't really need nor want that.

If anyone is interested, I'm willing to put the code here but I have to say that most of it isn't my work. I found some usefull code on the internet and adapted it to my needs.

Subject: Matlab GUI: displaying a Transfer Function in a static text box

From: roobi o

Date: 1 Nov, 2010 20:03:04

Message: 8 of 10

Hello
I have multiple results that I want to display in Edit Text
but I can not use this :set(handles.text1,'String',T);


for example I want to display following results in Edit text :


Number of station= 2
Number of Observation= 21

Adjusted coordinates
X y
100.01 11.09
111 23.78

Covariance Matrix
1
4
6
5
11
9



I have all these result from my function in GUI and I want to display them in Edit text and then save them in text file.

tnx

Subject: Matlab GUI: displaying a Transfer Function in a static text box

From: ser sank

Date: 20 Feb, 2011 15:50:33

Message: 9 of 10

This works for me:
---
function pushbutton2_Callback(hObject, eventdata, handles)
k=tf([1 1],[2 2 9]);
T=evalc('k');
%set(handles.textprinter1, 'String', mass);
set(handles.textprinter1, 'String', T);
---
Tschuss!

Subject: Matlab GUI: displaying a Transfer Function in a static text box

From: Tuan Razis

Date: 17 Apr, 2013 19:05:07

Message: 10 of 10

can u send your code to my email sir..

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