Pregunta

I've used MATLAB and pdfLatex but now I'm trying to combine them. I've found that you can call pdflatex with a ! in MATLAB and that seems to work but I want the filename that get's latexed to be dynamic (i.e. a variable) Here is my code (MATLAB) functionally.

for loop starts here
filename = concatinate(these variables/text strings.tex)

open file
write (fprintf) this latex code to filename (this part works)
close file

!pdflatex filename
for loop ends here

If I type the exact file name (file.tex) after !pdflatex it works, but the filename changes and I need it to produce about 80 files. Is there a way to make pdflatex evaluate the variable so that I can create these files in the code instead of one by one?

Thanks. Gizm0

Update: Thanks to @Luis Mendo my program is now calling pdflatex and working on some of the files, but I am getting this error on many lines.

! Text line contains an invalid character.

Here is an example of one of the lines:

\noindent 

When I copied and pasted the line above that is what showed up, but the line on the screen looks like this:

\noindent Good Instructor. \\

If I retype the line it works fine, but there is something weird about the way MATLAB is writing the line to the tex file that is making it invalid. The \noindent and \ are printed directly. "Good Instructor." comes from a variable.

I tried converting the tex file to a txt file and now that line looks like this:

\noindent    G o o d   i n s t r u c t o r . \\

Any ideas?

¿Fue útil?

Solución

Use system instead of !. It does the same thing but lets you build the string dynamically:

system(['pdflatex ' filename])
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top