Error with using sprintf

6 Ansichten (letzte 30 Tage)
James
James am 14 Aug. 2020
Kommentiert: James am 14 Aug. 2020
% Write output to text file
fn = sprintf('%s_%s_.txt',filtered.SD,out.mys);
fid = fopen('.txt','wt');
fprintf('%.0f\n',n,x);
fclose(fid);
Error using sprintf
Function is not defined for 'cell' inputs.
Error in tSes (line 39)
fn = sprintf('$s_%s_.txt',filtered.SD,out.mys);
>>
I am getting the above error message using sprintf. What is wrong with the code? Any help is appreciated.
  1 Kommentar
KSSV
KSSV am 14 Aug. 2020
It looks filtered.SD is a cell....what is it? What you expect?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 14 Aug. 2020
>> a={'abc'}
a =
1×1 cell array
{'abc'}
>> sprintf('%s',a)
Error using sprintf
Function is not defined for 'cell' inputs.
>> sprintf('%s',a{1})
ans =
'abc'

Weitere Antworten (0)

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by