필터 지우기
필터 지우기

Problem with char format values

조회 수: 1 (최근 30일)
hoda kazemzadeh
hoda kazemzadeh 2018년 6월 14일
댓글: Jan 2018년 6월 14일
I have a csv file and I need to read that file and I use in the title of wav file which I write using audiowrite.
Tb = readtable('configuration.csv');
TypeCapteur=char(Tb.TypeCapteurR);
Nom=char(Tb.NomR);
NumeroSerie=char(Tb.NumeroSerieR);
ConversionFactor=Tb.CorrectionCalibrationR;
filename=[TypeCapteur,'_', Nom,'_', NumeroSerie,'_', num2str(ConversionFactor),'.wav'];
infotitle=filename
audiowrite(filename,X,48000,'BitsPerSample',24,'Title',infotitle);
I got this error:
Failed to write 'Title' property to the file. WAV files do not support non-ASCII characters for metadata.
But when I replace the variables to char like the following, It works:
TypeCapteur='MIC';
Nom='n';
NumeroSerie='s';
in both cases they have 'char' format , why it does not work when I read from table and convert it to 'char' ?

답변 (1개)

Jan
Jan 2018년 6월 14일
Matlab's char values can contain Unicode characters with 16 bits, but ASCII means 8 bits (or maybe only 7).
Please post the contents of the file or the value of filename. How could we guess correctly, what the problem is without knowing the contents?
You can try
filename = char(uint8(filename))
but maybe this creates garbage when the original name contains meaningful unicode characters.
  댓글 수: 2
hoda kazemzadeh
hoda kazemzadeh 2018년 6월 14일
it says: Conversion to uint8 from cell is not possible.
Nom,TypeCapteur,.. are string array with maximum 14 characters.
Jan
Jan 2018년 6월 14일
Please post a copy of the complete message in every case. A rough summary can hide important details.
I asked you to post the contents of the file and the contents of the variable filename. Ignoring questions for clarifications looks, like you are not interested in a solution.
Nom,TypeCapteur,.. are string array with maximum 14 characters.
This really strange after a casting to a char. I do not believe, that you get an array of type string afterwards.
After:
filename=[TypeCapteur,'_', Nom,'_', NumeroSerie,'_', num2str(ConversionFactor),'.wav'];
it is impossible, that filename is a cell array.
Please post the code you really use, a copy of the complete error message and the inputs.

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

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by