a way to use an empty char cell in inputdlg
Afficher commentaires plus anciens
Hi, and Merry Christmas at all
I need to use an inputdlg box with La Tex interpreter setted at
options.Interpreter = 'tex';
my prompts return from a for loop; so I used sprintf function:
for i=1:3
w = sprintf('\\alpha\ %d', i);
e = sprintf('A %d', i);
r = sprintf('\\theta\ %d', i);
q = sprintf('D %d', i);
z = sprintf('\\sigma\ %d (rot=0, prism=1)', i);
Title = sprintf('LINK %d',i);
prompt = {w,e,r,q,z};
numlines=1;
answer=inputdlg(prompt,Title,numlines,defans, options);
but, since I don't care default answer, I thought to assign it an empty space like:
defans = {'','','','',''};
or
defans = cell(1,5);
defans{1} = char(defans{1});
defans{2} = char(defans{1});
defans{3} = char(defans{1});
defans{4} = char(defans{1});
defans{5} = char(defans{1});
but in both cases matlab returns the same warning message:
Warning: Escape sequence ' ' is not valid. See 'help sprintf' for valid escape
sequences.
I think because '' form is an Escape sequence for sprintf() function.
How can I use the LaTex interpreter and an empty space as default answer without Warning Message returning ?
1 commentaire
Kye Taylor
le 28 Déc 2012
Merry Christmas and all back at ya! haha
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 24 Déc 2012
0 votes
backslash followed by space is not a valid sprintf() escape sequence.
Perhaps you need to use (e.g.) '\\\\alpha\\ %d'
10 commentaires
Marco
le 24 Déc 2012
Marco
le 24 Déc 2012
Walter Roberson
le 24 Déc 2012
Use your debugger and step through that code; you will be able to isolate where the warnings are coming from.
Jan
le 27 Déc 2012
@Marco: Why do you think, that the problem appears in defans = {'','','','',''}? sprintf('\ ') reproduces the warning, such that I'm convinced, that Walter is right.
Another way to create your default answer:
defans = cell(1,5);
defans(:) = {''};
Marco
le 27 Déc 2012
Walter Roberson
le 27 Déc 2012
Try '\\alpha %d\\ '
Marco
le 28 Déc 2012
Jan
le 28 Déc 2012
What about omitting the trailing slash?
Walter Roberson
le 28 Déc 2012
What string is it that you would like to reach LaTex ?
Marco
le 29 Déc 2012
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!