Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

1,330 views
Skip to first unread message

RobuLAB

unread,
May 17, 2010, 5:31:03 AM5/17/10
to
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

Steven Lord

unread,
May 17, 2010, 9:33:38 AM5/17/10
to

"RobuLAB " <amaur...@etu.u-bordeaux1.fr> wrote in message
news:hsr2cn$4mf$1...@fred.mathworks.com...

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
sl...@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


RobuLAB

unread,
May 17, 2010, 11:05:05 AM5/17/10
to
"Steven Lord" <sl...@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?

Craig Buhr

unread,
May 18, 2010, 11:23:31 AM5/18/10
to
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 " <amaur...@etu.u-bordeaux1.fr> wrote in message

news:hsrlv1$pkp$1...@fred.mathworks.com...

RobuLAB

unread,
May 19, 2010, 5:50:04 AM5/19/10
to
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" <cb...@mathworks.com> wrote in message <hsubdm$84r$1...@fred.mathworks.com>...

RICARDO SANCHEZ

unread,
May 24, 2010, 2:46:04 PM5/24/10
to
"RobuLAB " <amaur...@etu.u-bordeaux1.fr> wrote in message <ht0c8c$ne9$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);
*******************************

RobuLAB

unread,
May 25, 2010, 10:17:04 AM5/25/10
to
"RICARDO SANCHEZ" <ricardo...@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.

roobi o

unread,
Nov 1, 2010, 4:03:04 PM11/1/10
to
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

ser sank

unread,
Feb 20, 2011, 10:50:33 AM2/20/11
to
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!

Tuan Razis

unread,
Apr 17, 2013, 3:05:07 PM4/17/13
to
can u send your code to my email sir..

lucas...@gmail.com

unread,
Nov 16, 2014, 11:30:39 PM11/16/14
to
Its a little TOO late for an answer this, but for furter records, that didn't worked for me neither....

The only problem was the size of the text element.

Try making it bigger and check ;)

Regards

chuzairhab...@gmail.com

unread,
Apr 2, 2018, 10:48:56 AM4/2/18
to
i want to show pzmap of tranfer function in GUI
any suggestion,,,,plz




thanks in advance
0 new messages