Kiran
Kiran

Reputation: 8518

Suppress Escape Characters in 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

Upvotes: 7

Views: 4083

Answers (1)

Eitan T
Eitan T

Reputation: 32920

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.

Upvotes: 10

Related Questions