A column vector with words
Mostrar comentarios más antiguos
I am trying to get an SVM working, for that i need a column vecotor of lables. My first attempt resulted in the input of 'F' and 'H' being turned into numbers (this is the only thing that would not result in an error message.
I want a colum of words, names 'Friendly' and 'Hostile'
The simplified version of what I've got:
>> A=zeros(10,1);
>> A(1:5)='F';
>> A(6:10)='H';
>> A
A =
70
70
70
70
70
72
72
72
72
72
Respuestas (1)
Cris LaPierre
el 9 de Abr. de 2021
Editada: Cris LaPierre
el 9 de Abr. de 2021
All values in your variable must be of the same datatype. By creating your variable with the zeros function, you define A as being of type double, When you add a 'F' and 'H' to A, you are getting the ascii character code for those letters.
If you want to store letters or words, then your variable must be of type char or string.
A=strings(10,1);
A(1:5)='F';
A(6:10)='H'
Categorías
Más información sobre String Parsing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!