フィルターのクリア

array of strings into 2 number array

5 ビュー (過去 30 日間)
fima v
fima v 2017 年 2 月 17 日
コメント済み: Walter Roberson 2017 年 2 月 17 日
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 日
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 日
TAB = sprintf('\n');
output = str2double( cellfun(@(S) strsplit(S, TAB), YourCell, 'Uniform', 0) );
or
temp = regexp(YourCell, '\t', 'split');
output = str2double( vertcat(temp{:}) );

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by