Convert single string with many numbers to vector
이전 댓글 표시
I have the following string
hue = '10 20 30 40 50';
That I want to turn into a vector of those 5 values
hue_vec = [10 20 30 40 50];
How can I do this? Thanks in advance!
채택된 답변
추가 답변 (3개)
Fangjun Jiang
2019년 7월 31일
1 개 추천
a=str2num(hue);
Very simple, very efficient, no evil eval:
>> hue = '10 20 30 40 50';
>> vec = sscanf(hue,'%f',[1,Inf])
vec =
10 20 30 40 50
카테고리
도움말 센터 및 File Exchange에서 Sparse Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!