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개)

Cris LaPierre
Cris LaPierre 2021년 4월 9일
편집: Cris LaPierre 2021년 4월 9일

0 개 추천

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'
A = 10×1 string array
"F" "F" "F" "F" "F" "H" "H" "H" "H" "H"

카테고리

태그

질문:

2021년 4월 9일

편집:

2021년 4월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by