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:
How to print simple text to the console?

Subject: How to print simple text to the console?

From: Colin

Date: 16 Dec, 2008 16:48:02

Message: 1 of 7

Hi, I want to print error messages to the console when myfunction.m is used in the case that the input does not meet requirements.

Is there a simple function to print text?

Thanks.

Subject: How to print simple text to the console?

From: Kevin Neilsen

Date: 16 Dec, 2008 17:16:03

Message: 2 of 7

Disp('your message')

you could also do it through a pop up by using errordlg()

Subject: How to print simple text to the console?

From: Colin

Date: 16 Dec, 2008 17:36:03

Message: 3 of 7

Thanks you.

"Kevin Neilsen" <kevricio@hotmail.com> wrote in message <gi8noj$190$1@fred.mathworks.com>...
> Disp('your message')
>
> you could also do it through a pop up by using errordlg()

Subject: How to print simple text to the console?

From: Steven Lord

Date: 16 Dec, 2008 17:39:55

Message: 4 of 7


"Colin " <colinzhe@gmail.com> wrote in message
news:gi8m42$42s$1@fred.mathworks.com...
> Hi, I want to print error messages to the console when myfunction.m is
> used in the case that the input does not meet requirements.
>
> Is there a simple function to print text?

Yes, you could DISP or FPRINTF, but instead you probably want to terminate
the execution of your function, right? In that case, use ERROR or create
and THROW an MException.

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/error.html

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/mexception.html

--
Steve Lord
slord@mathworks.com

Subject: How to print simple text to the console?

From: gwideman

Date: 15 Nov, 2014 11:48:08

Message: 5 of 7

Several responders suggest the Disp() or DISP() functions. I don't know about you, but those just give me a big fat "Undefined function or variable 'Disp'".

Seems that the correct name is disp() (lower case).

-- Graham

Subject: How to print simple text to the console?

From: Steven Lord

Date: 17 Nov, 2014 14:39:47

Message: 6 of 7


"gwideman " <noemail@address.com> wrote in message
news:m47eho$aa1$1@newscl01ah.mathworks.com...
> Several responders suggest the Disp() or DISP() functions. I don't know
> about you, but those just give me a big fat "Undefined function or
> variable 'Disp'".
>
> Seems that the correct name is disp() (lower case).
>
> -- Graham

When I write comments that name a MATLAB function, unless that function's
name uses camelCase (like inputParser) I generally write it in ALL CAPS to
make it stand out. I believe that others often do the same. Example:

    Compute the sine of an angle using the SIN function, like "y = sin(pi)".

DISP is one function that you can use to display text, yes. Depending how
much control you want over the formatting, FPRINTF may also be of interest
to you.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: How to print simple text to the console?

From: Rob Campbell

Date: 18 Nov, 2014 15:49:12

Message: 7 of 7


> When I write comments that name a MATLAB function, unless that function's
> name uses camelCase (like inputParser) I generally write it in ALL CAPS to
> make it stand out. I believe that others often do the same. Example:

This can be quite a confusing way of doing things. Just today I came accross a function that was described ALL CAPS but was instead camel case. I find it makes more sense to use the actual case of the function rather than change it some times but not other times.

Tags for this Thread

No tags are associated with 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