How I convert a str to Num, and label them. please help me.
이전 댓글 표시
Dear Sir/Madam,
I am a beginner of MATLAB please help me, here is my prog. the below program i want to convert a string into number want a label by connecting diffident string like.
Function num_arr=convert_to_num420(str_cell_arr)
num_arr=zeros(length(str_cell_arr),1);
strs=unique(str_cell_arr);
for i=1:length(str_cell_arr)
for j=1:length(strs)
if strcmp(str_cell_arr{i},'normal.')
num_arr(i)= 1; % upto here prog is fine but next line i got error "like too many parameters"
"sir here i want to convert all the string into num. that is equal to 2" below line.
if strcmp(str_cell_arr{i},'back.','land.','neptune.','pod.','smurf.','teardrop.')
num_arr(i)= 2;
break;
else
num_arr(i)= -1;
end
end
end
end
채택된 답변
추가 답변 (1개)
Walter Roberson
2015년 9월 17일
편집: Walter Roberson
2015년 9월 17일
if ismember(str_cell_arr{i}, {'back.', 'land.', 'neptune.', 'pod.', 'smurf.', 'teardrop.'})
댓글 수: 4
Rehan Ali
2015년 9월 17일
Walter Roberson
2015년 9월 17일
What is some sample input that you are calling the routine with?
Rehan Ali
2015년 9월 17일
Rehan Ali
2015년 9월 17일
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!