Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress Escape Characters in Matlab

Tags:

printf

matlab

I am writing a module in Matlab to enter the configuration parameters of my experiment to a file 'parameters.txt'.

Here is the module which does that :

for i=1:size(ParamSheetText,1)
    fprintf(fparam, ParamSheetText{i,1});
    fprintf(fparam,'\n');
end

One of the parameter is the folder location : "D:\temp". fprintf is interpreting \t as a escape sequence. Is there any way that I can suppress the escape sequence or modify the code so that escape sequence is suppressed.

Thanks

like image 466
Kiran Avatar asked Jan 27 '13 12:01

Kiran


1 Answers

fprintf is parsing escape sequences only in format strings, so you shouldn't be passing your data string as a format string (but rather as an additional argument following the format specifier):

fprintf(fparam, '%s', ParamSheetText{i,1});

I believe this will correct your issue.

like image 146
Eitan T Avatar answered Sep 28 '22 13:09

Eitan T