# Decimal Comma in Matlab Plots

A lot of languages (not only the European ones) use **decimal comma** instead decimal point to separate the whole and the fractional part of a number in decimal form. **Matlab** (like other programs) uses decimal point for this purpose. This is okay when using it for computations but it is better to use decimal comma in graphs embedded in documents written in some European language.

This approach also works in **GNU Octave** which is available for free. ;-)

Basic plotting in Matlab is done by the plot function:

To change decimal point to decimal comma I used simple approach: Function *get(gca, ‘XTick’)* returns the tick of X asix. In our case it is a vector -1:0.01:1. Another function *set(gca, ‘XTickLabel’)* sets a label for X axis. This label contains cell array of strings. The only necessary step between calling these functions is to change decimal points to commas using the strrep function.

I wrapped this code into a simple function **decimal_comma** with a few arguments:

**axes_handle**is handle of axes to be changed. Just enter gca for current plot.**axis_name**is the name of axis to be changed:*'X'*,*'Y'*or*'XY'*for both axes.**formatstr**(optional) is simple sprintf-like format string, e.g.*'%2.2f'*

Just copy the code below and save it into new script file named decimal_comma.m or clone the whole **Github repository**:

Usage for our example function *y*=*x*^{3}:

If you like to hide numbers on the left and right, just add this line before *set(axis_handle, …)*:

The plot will then change to:

Get the whole code from my Github!