Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't MATLAB plot the word "factory"?

Consider the following MATLAB code:

text(0, 0, 'factory');
xlim([-1, 1]);
ylim([-1, 1]);

The intended goal is to have a figure with the word "factory" in it. No word appears. Now replace the word "factory" by any other word and the above code works as intended. This has been tested with MATLAB 2017b and 2015b

Does anyone know what's going on here?

like image 577
Marijn van Vliet Avatar asked Apr 18 '18 12:04

Marijn van Vliet


1 Answers

Problem Explained

According to MATLAB title function documentation:

The words default, factory, and remove are reserved words that will not appear in a title when quoted as a normal character vector. To display any of these words individually, precede them with a backslash, such as '\default' or '\remove'.

This logic apply for text function as well. The Default Property Values page supplies more details about the role of factory keyword and why we can't use it as a parameter for graphic functions.

Solution

The following code works fine:

text(0, 0, '\factory');
xlim([-1, 1]);
ylim([-1, 1]);
like image 187
ibezito Avatar answered Nov 16 '22 03:11

ibezito