How can I extract the values form the cell array?

1 Ansicht (letzte 30 Tage)
Ali Mahdi
Ali Mahdi am 10 Okt. 2021
Bearbeitet: Chunru am 10 Okt. 2021
I have a cell array as follow:
[{'name': 'Monday', 'data': [0, 0, 0, 0, 0, 0, 0, 0, 44, 56, 58, 57, 62, 71, 73, 64, 47, 29, 0, 0, 0, 0, 0, 0]}, {'name': 'Tuesday', 'data': [0, 0, 0, 0, 0, 0, 0, 0, 60, 66, 61, 81, 91, 85, 67, 45, 0, 0, 0, 0, 0, 0, 0, 0]}, {'name': 'Wednesday', 'data': [0, 0, 0, 0, 0, 0, 0, 0, 60, 98, 84, 67, 72, 76, 69, 53, 0, 0, 0, 0, 0, 0, 0, 0]}, {'name': 'Thursday', 'data': [0, 0, 0, 0, 0, 0, 0, 0, 88, 82, 50, 43, 58, 69, 63, 44, 0, 0, 0, 0, 0, 0, 0, 0]}, {'name': 'Friday', 'data': [0, 0, 0, 0, 0, 0, 0, 0, 57, 90, 100, 90, 81, 74, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, {'name': 'Saturday', 'data': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, {'name': 'Sunday', 'data': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}]
Now i need to extract the values for each day in a able contain the day and its values as shown below;
Monday Tuesday ....
0 0
0 0
0 0
0 0
044 60
58 66
.... ....
Kindly suggest me if there is any function to deal with this.
Thank you in advances

Akzeptierte Antwort

Chunru
Chunru am 10 Okt. 2021
Bearbeitet: Chunru am 10 Okt. 2021
Obviously, you don't have a matlab cell array (is it a python array?). The matlab array may look like the following:
a(1).name='Monday';
a(1).data=[0, 0, 0, 0, 0, 0, 0, 0, 44, 56, 58, 57, 62, 71, 73, 64, 47, 29, 0, 0, 0, 0, 0, 0]';
a(2).name='Tuesday';
a(2).data =[0, 0, 0, 0, 0, 0, 0, 0, 60, 66, 61, 81, 91, 85, 67, 45, 0, 0, 0, 0, 0, 0, 0, 0]';
a(3).name='Wednesday';
a(3).data=[0, 0, 0, 0, 0, 0, 0, 0, 60, 98, 84, 67, 72, 76, 69, 53, 0, 0, 0, 0, 0, 0, 0, 0]';
% The same for the rest
[a.data]
ans = 24×3
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 44 60 60 56 66 98

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by