A column vector with words
이전 댓글 표시
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
답변 (1개)
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'
카테고리
도움말 센터 및 File Exchange에서 String Parsing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!