"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.

"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.

> 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.