Problem with char format values
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Jan
le 14 Juin 2018
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 commentaires
Jan
le 14 Juin 2018
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.
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!