matlab2tikz error
Submitted by Anonymous on Wed, 26/05/2010
Im using v0.0.6 (tried earlier versions as well), with Matlab 2009a. When i run matlab2tikz i get the following error message, and i cant seem to figure it out. Anyone?
??? Error: File: matlab2tikz.m Line: 3992 Column: 17
Expression or statement is incorrect--possibly unbalanced (, {,
or [.
Forums:

Hi, I guess, it would be
Hi,
I guess, it would be helpful, if you could provide the MATLAB code for your plot (or a minimal, reduced similar code) until Nico could have a look at it.
I had a quick look at it (0.0.6) and found:
[~,idx]The error could arise from the 'tilde'-operator, which is a new way in the latest MATLAB version to suppress unwanted return values of functions.
Thank you for the reply. I've
Thank you for the reply.
I've been trying with really simple matlab plots (e.g. 'plot(1:1:100)').
I also suspected that the tilde-part might be the problem. I tried version 5 again, and it worked (must have screwed up something the first time i tried), but i would like to use the height/length functionality from version 6.
Yeah, it seems that a lot of
Yeah, it seems that a lot of people bump into this ~-issue as they haven't upgraded to MATLAB 2009b yet, although it's not the latest version yet.
Maybe the ~-notation should be suspended from matlab2tikz for another year or two.
Thanks, problem identified.
Thanks, problem identified.
Do you know if there is some sort of easy hack to fix it? Maybe some equivalent syntax in older matlab versions? I'm not familiar with the tilde operator, except the explanation on Mathworks' website.
http://www.mathworks.co.jp/access/helpdesk/help/techdoc/rn/br5fo8o-1.html
Workaround easy
The workaround is easy:
~-operator is used in cases when a function as two return arguments, and you just need the second one; to save memory, you can put~in the place of the first return argument, i.e.,[~, alpha] = my_fun();
If that don't work, you can just assign the first value, i.e.,
[dummy, alpha] = my_fun();
and then not use
dummy. That's a bit nasty though, and I'd like to have it removed sometime. The real fix would be to upgrade MATLAB® of course!I'll try it out as soon as
I'll try it out as soon as possible, and try to convince the IT-guys to update. Until then i am coping with version 5.
Anyways, thanks for the help, and for a great script.