Extract data directly from several vectors within a cell array in Matlab

baister

I have a structure like this one:

>> A = [1 2; 3 4];
>> B = [5 6; 7 8];
>> C = [9 10; 11 12];
>> D = [13 14; 15 16];
>> S = {A B; C D}

S = 

[2x2 double]    [2x2 double]
[2x2 double]    [2x2 double]

I wonder if there is any way to extract the first element of each array within the cell array by using just one command. For example, I would like to get

ans = [S{1,1}(1) S{1,2}(1); S{2,1}(1) S{2,2}(2)]

ans =

 1     5
 9    15

but automatically and in a programmable way, i.e. using colons or similar.

Loops are not desired.

Is it possible?

Thank you.

Etienne

You can use cellfun :

FirstElement = cellfun(@(x)x(1),S)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Delete vectors from cell array elements in MATLAB

From Dev

Extract specific values from cell based on array in MATLAB

From Dev

Matlab Cell Array Data

From Dev

Directly getting the elements of an array/cell in Matlab

From Dev

Directly getting the elements of an array/cell in Matlab

From Dev

using Matlab to reshape a 4d matrix into a cell array of vectors

From Dev

Substrings from a Cell Array in Matlab

From Dev

Substrings from a Cell Array in Matlab

From Dev

Excel - extract unique values from a column with several values in each cell

From Dev

Extracting and arranging nested data within cell array

From Dev

How can extract elements from a cell array

From Dev

Classify data (cell array) based on years in MATLAB

From Dev

create a paired value cell array from existing vectors

From Dev

irb extract Strings from within array

From Dev

How to extract cell from pandas data frame

From Dev

Extract data separated by a comma from a single cell

From Dev

How to extract cell from pandas data frame

From Dev

How to Extract Relevant Data from cell

From Dev

Extract multiple data from cell in Excel

From Dev

How do I extract text and numbers from a string within a cell?

From Dev

Extract data from within parenthesis in python

From Dev

Extracting a specific element from each cell within cell array

From Dev

Extracting a specific element from each cell within cell array

From Dev

making legend from a cell array in matlab

From Dev

Matlab Extracting sub string from cell array

From Dev

Removing elements from a cell array in MATLAB

From Dev

collect and increment cell array from loop matlab

From Dev

Making a matrix from several vectors

From Dev

Extract blocks of numbers from array in Matlab

Related Related

  1. 1

    Delete vectors from cell array elements in MATLAB

  2. 2

    Extract specific values from cell based on array in MATLAB

  3. 3

    Matlab Cell Array Data

  4. 4

    Directly getting the elements of an array/cell in Matlab

  5. 5

    Directly getting the elements of an array/cell in Matlab

  6. 6

    using Matlab to reshape a 4d matrix into a cell array of vectors

  7. 7

    Substrings from a Cell Array in Matlab

  8. 8

    Substrings from a Cell Array in Matlab

  9. 9

    Excel - extract unique values from a column with several values in each cell

  10. 10

    Extracting and arranging nested data within cell array

  11. 11

    How can extract elements from a cell array

  12. 12

    Classify data (cell array) based on years in MATLAB

  13. 13

    create a paired value cell array from existing vectors

  14. 14

    irb extract Strings from within array

  15. 15

    How to extract cell from pandas data frame

  16. 16

    Extract data separated by a comma from a single cell

  17. 17

    How to extract cell from pandas data frame

  18. 18

    How to Extract Relevant Data from cell

  19. 19

    Extract multiple data from cell in Excel

  20. 20

    How do I extract text and numbers from a string within a cell?

  21. 21

    Extract data from within parenthesis in python

  22. 22

    Extracting a specific element from each cell within cell array

  23. 23

    Extracting a specific element from each cell within cell array

  24. 24

    making legend from a cell array in matlab

  25. 25

    Matlab Extracting sub string from cell array

  26. 26

    Removing elements from a cell array in MATLAB

  27. 27

    collect and increment cell array from loop matlab

  28. 28

    Making a matrix from several vectors

  29. 29

    Extract blocks of numbers from array in Matlab

HotTag

Archive