File Exchange

image thumbnail


version (5.8 KB) by Mark Brown
General replacement for fprintf which allows printing formatted text to separate editable window.


Updated 31 Mar 2016

View Version History

View License

GPRINTF is a general replacement for the built-in fprintf function. In addition to printing to a file or the command window, GPRINTF can print formatted output to one or more display windows. Each display window has automatic scroll bars and can be independantly positioned and editted. This distribution includes an S-function wrapper for use with Simulink.
Features include:
File: open, save, save as, close
Edit: cut, copy, paste, clear
Format: font, wrap (on/off)
Automatic vertical / horizontal scroll bars
Full access to text and display properties via object handle.

>> gprintf(-1,'pi is approximately = %6.4f\n',pi)
>> gprintf(-1,'HELLO WORLD\n')

creates "Display Box 1" with the string "pi is approximately = 3.1416" on the first line and "HELLO WORLD" on the second line. Use the pull-down menus to customize the display or save its contents to a file.

Cite As

Mark Brown (2021). GPRINTF (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Ronan Costello

Nice function.

I would like to make the text box scroll down with each new line, at the moment it seems to stay at line 1 and new lines go off bottom of the box. Any ideas on how to fix this??


Thierry Dalon

Maybe jprintf is the newest version but I still prefer gprintf.
Inconvenient of jprintf is that you can not change window properties like Name etc directly. (or you need to know how to do this with Java commands)
I prefer the "old" gprintf. here you get a real Matlab figure and can change its properties via usual Matlab commands.

Thierry Dalon

With R2008a I had to move :
hact = actxcontrol('Forms.TextBox.1',[0 0 400 200]);

it seems that by setting the resizefcn the resizefcn callback is executed.
A Matlab bug?
With this modification, function works perfectly.

Mark Brown

Please see JPRINTF (by the same author) as well. JPRINTF is done entirely in Java and should be more portable across platforms.

Daniel K. O'Brien

This module provides an excellent tool for displaying Text and Numerics in a window.
After updating two files as recommended in the package, I was fully able to use the package
as defined in the abstract. This is an EXCELLENT !!! package.

I only features that I would add to the package, would be the Print Preview and Print cabability
via the drop down menu of the module.


MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!