MATLAB Answers

Extract entire matrices from a cell

2 views (last 30 days)
AS
AS on 28 Jan 2020
Commented: AS on 28 Jan 2020
Hallo,
I have a cell which contains 10 matrices. Each matrix contains data from a different sensor and all matrices have different number of rows although they have the same number of columns. I would like to extract the entire matrices from the cell and keep the name of each matrix.
Thanks in advance

  5 Comments

Show 2 older comments
Stephen Cobeldick
Stephen Cobeldick on 28 Jan 2020
You state in your question that you "...have a cell which contains 10 matrices", but your screenshot clearly shows a scalar structure with ten fields:
What is stopping you from simply accessing the data from that structure?
Dynamically naming matrics is unlikely to be a good approach:
Walter Roberson
Walter Roberson on 28 Jan 2020
Leave them in the struct. Use structfun() . Or use struct2cell() and cellfun()
AS
AS on 28 Jan 2020
You are write, its a structure and it is better to do al the calculations inside the structure.

Sign in to comment.

Answers (1)

Selva Karna
Selva Karna on 28 Jan 2020
clc
clear all;
close all;
cel_len=length(your_cell);
for i=1:cel_len
exta_cel=your_cell(i);
ext_data(i)=ext_cel
end

  1 Comment

AS
AS on 28 Jan 2020
Thanks for the answer. However this solution creates again the new structure ext_data with the same matrices.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!