# Converting Cell matrix to a Numeric Matrix

3 views (last 30 days)
Souarv De on 12 May 2021
Commented: Souarv De on 12 May 2021
I have a cell matrix as shoown below.
B={'2' '3' '5'; '4' '7' '2'; '7' '5' '2'}
B =
3×3 cell array
{'2'} {'3'} {'5'}
{'4'} {'7'} {'2'}
{'7'} {'5'} {'2'}
I want to convert it a numeric matrix like as follows:
A =
2 3 5
4 7 2
7 5 2
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Stephan on 12 May 2021
Edited: Stephan on 12 May 2021
B={'2' '3' '5'; '4' '7' '2'; '7' '5' '2'}
B = 3×3 cell array
{'2'} {'3'} {'5'} {'4'} {'7'} {'2'} {'7'} {'5'} {'2'}
C = cellfun(@(x)str2double(x),B)
C = 3×3
2 3 5 4 7 2 7 5 2
##### 3 CommentsShowHide 2 older comments
Souarv De on 12 May 2021
Woow. That's one is more easier to remember. Thanks to you once again Stephen.

Sign in to comment.

### Categories

Find more on Logical in Help Center and File Exchange

R2018a

### Community Treasure Hunt

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

Start Hunting!