nschloe/matlab2tikz — Issue #55: determining scaling factor error
Author: lucvandort
Created: 2011-12-04 16:26:11+00:00
State: open

If you create a plot in matlab with custom ticks and labels, if there is only 1 specified tick at x/y/z=0 (for example when plotting only the x- and y-axes with no further grid), the matlab2tikz function of determining the scaling factor fails. Line 3851 of matlab2tikz.m is:

k = find( tick, 1 );

but find only looks for nonzero values. If there is only one value, and that is zero, this function returns an empty matrix. The next line then returns an error, because str2double can't work with nothing.

s = str2double( tickLabel{k} );

Should be easy to solve with an if-statement, I guess? I couldn't do it myself for now, as the value of k is also used in some further functions, but I will try to see if I can come up with a solution in code. Maybe someone who knows how the code works exactly could do it in a few seconds?

Regards, Luc