Say I have a cell array:
C = {'2_5_7';'10_2_6';'4_3_7';'3_10_11';'3_16_11'};
To extract one row as a vector of number I was using:
sscanf(C{[2]},'%d_')'
ans =
10 2 6
Now I would like to get several rows (say 2 and 4) in form of a matrix, but this does not work.
The desired output for this case should be:
I would like to avoid the use of a for loop.Any suggestions?
EDIT: The elements of C dont necesarilly contain only 3 number, they can contain 4 or more. ie '3_10_11_5'
2 Comments
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/587108-sscanf-with-cell-array-of-strings#comment_992474
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/587108-sscanf-with-cell-array-of-strings#comment_992474
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/587108-sscanf-with-cell-array-of-strings#comment_992501
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/587108-sscanf-with-cell-array-of-strings#comment_992501
Sign in to comment.