Effacer les filtres
Effacer les filtres

pass matlab variables to text file

2 vues (au cours des 30 derniers jours)
Gerrit
Gerrit le 17 Fév 2014
Modifié(e) : Mischa Kim le 17 Fév 2014
Hey, I've got a few variables that need to be shown in speficic spots in a html-file. The html-code already exists, including the variables' positions (positions are acually defined in the html-code!), so all I want to do is pass the variables from matlab to the html-file. I've tried using fprintf but it only seems to be able to actually write variables into a html-file, not just pass them. I'v chosen this way because it doesn't seem to be possible to position variables properly (as in specific pixel position) by using fprintf. Please let me know if I'm wrong because this way would of course be an option!
Does anyone know how to solve this one? Like how do I tell Matlab to write its variables into the variables defined in the html-code, not create its own.
I basically use the typical fprintf-code x = get(handles.x,'string'); fid = fopen(test.htm,'a'); fprintf(fid,['some html string',x]); fclose(fid);

Réponse acceptée

Mischa Kim
Mischa Kim le 17 Fév 2014
Modifié(e) : Mischa Kim le 17 Fév 2014
Gerrit, I believe you already got most of what you need:
my_var = 3;
fid = fopen('test.htm','a');
fprintf(fid, ['<H2>My test input</H2>']);
fprintf(fid, ['\n<BR>Variable my_var = ', num2str(my_var)]);
fclose(fid)
Make sure that the filename is a string of characters. Does this answer your question?

Plus de réponses (0)

Catégories

En savoir plus sur Data Import and Export dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by