How can I extract the values form the cell array?

1 回表示 (過去 30 日間)
Ali Mahdi
Ali Mahdi 2021 年 10 月 10 日
編集済み: Chunru 2021 年 10 月 10 日
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

採用された回答

Chunru
Chunru 2021 年 10 月 10 日
編集済み: Chunru 2021 年 10 月 10 日
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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by