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

Print Command

Asked by Shavi on 15 May 2012

Hello

Can anybody tell me that how to use the print command in matlab?

As i want to get the data from the textbox and print that particular data. not the whole figure.

Please anybody help..

2 Comments

Walter Roberson on 15 May 2012

"print" is for creating the kinds of outputs that might be sent to a printer. Is that what you want? Or are you looking to create a text file?

Shavi on 15 May 2012

Ya i want to use the print command or print function.
I have to take the data from the text box and get it printed solely.

So what is the coding used for this?

Shavi

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson on 15 May 2012

Let h be the handle of the uicontrol of style Text. Then

h_handle = handle(h);
h_image = h_handle.getPrintImage;

At this point, h_image will be an RGB array containing a rendered copy of the text. You can now figure() a new figure, image() h_image into the new figure, and print() the new figure.

You might wish to consider, however, using imwrite() on h_image to save it to an image file that you can print using your system utilities.

I have my doubts that any of this is what you really want to do, but...

18 Comments

Walter Roberson on 25 May 2012

I think I have access to that version at work; I will need to check tomorrow.

Shavi on 25 May 2012

k

Walter Roberson on 25 May 2012

Yes, I do have R2010b at work, and yes it does have getPrintImage

>> h = uicontrol('style','edit','String','hello there')

h =

0.0009765625

>> hh = handle(h)

hh =

uicontrol

>> methods(hh)

Methods for class hg.uicontrol:

getGUIDEView getPrintImage

>> hh.getPrintImage

ans(:,:,1) = [...]

Walter Roberson

Contact us