Error with using sprintf

10 vues (au cours des 30 derniers jours)
James
James le 14 Août 2020
Commenté : James le 14 Août 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 commentaire
KSSV
KSSV le 14 Août 2020
It looks filtered.SD is a cell....what is it? What you expect?

Connectez-vous pour commenter.

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 14 Août 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'
  1 commentaire
James
James le 14 Août 2020
Thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by