Hello, i have an array of 3 strings,each string is consists of two numbers spaced by tab. i would like to create a 2X3 2D array.i thought of going with for loop using strsplit and str2num. is there an easier way,without for loop?
Thanks

댓글 수: 1

Walter Roberson
Walter Roberson 2017년 2월 17일
Is this a cell array of strings, or a char array?

댓글을 달려면 로그인하십시오.

 채택된 답변

KSSV
KSSV 2017년 2월 17일

1 개 추천

str = {'apple' 'boy'} ; % you may take numbers
repmat(str,2,3)

댓글 수: 1

Walter Roberson
Walter Roberson 2017년 2월 17일
? This does not appear to be related to the needs of the Question ?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2017년 2월 17일

2 개 추천

TAB = sprintf('\n');
output = str2double( cellfun(@(S) strsplit(S, TAB), YourCell, 'Uniform', 0) );
or
temp = regexp(YourCell, '\t', 'split');
output = str2double( vertcat(temp{:}) );

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2017년 2월 17일

댓글:

2017년 2월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by