Problem with char format values
4 次查看(过去 30 天)
显示 更早的评论
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' ?
0 个评论
回答(1 个)
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 个评论
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 Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!