Error with using sprintf

조회 수: 6 (최근 30일)
James
James 2020년 8월 14일
댓글: James 2020년 8월 14일
% 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
KSSV
KSSV 2020년 8월 14일
It looks filtered.SD is a cell....what is it? What you expect?

댓글을 달려면 로그인하십시오.

채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 8월 14일
>> 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
James
James 2020년 8월 14일
Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by