Borrar filtros
Borrar filtros

Problem with char format values

1 visualización (últimos 30 días)
hoda kazemzadeh
hoda kazemzadeh el 14 de Jun. de 2018
Comentada: Jan el 14 de Jun. de 2018
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' ?

Respuestas (1)

Jan
Jan el 14 de Jun. de 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 comentarios
hoda kazemzadeh
hoda kazemzadeh el 14 de Jun. de 2018
it says: Conversion to uint8 from cell is not possible.
Nom,TypeCapteur,.. are string array with maximum 14 characters.
Jan
Jan el 14 de Jun. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by