How to Access and Rename Doubles that are Stored in a Large Cell

조회 수: 1(최근 30일)
Pat 2020년 2월 17일
댓글: Stephen 2020년 2월 18일
I have a Cell that is 1x193. Each of the 193 elements is a 500x100 double.
I need to be able to access every element in this cell and rename each double to be Data1, Data2, Data3, etc. such that I can perform means on the rows of Data1, Data2, etc.
Does anyone have suggestions for how to accomplish this?
  댓글 수: 2
Pat 2020년 2월 18일
I did come across that link while looking into this, but I didn't have a good workaround for it.
I understand what you are saying, but I don't really know what syntax I should use to do accomplish this...

댓글을 달려면 로그인하십시오.


Bhaskar R
Bhaskar R 2020년 2월 17일
You no need to rename every elecment(500x100 double) of the cell which leads much complications, you can perform your operation directly using command cellfun
result_mean = cellfun(@(x)mean(x, 2), cell_array, 'UniformOutput', false); % cell_array is your vartiable
You can access mean values of the data as
result_mean{1}, result_mean{2}..result_mean{193}; % for mean values of the each row of the double array
  댓글 수: 5
Stephen 2020년 2월 18일
Do NOT use datastore as a variable name, it is the name of an important inbuilt function.
Where C is your cell array, calculate the mean of each row:
A = cat(3, C{:});
M = mean(A,2)
It will have size 500x1x193. Use indexing to access particular pages, or permute or reshape to rearrange those dimensions. Avoid squeeze.

댓글을 달려면 로그인하십시오.


Community Treasure Hunt

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

Start Hunting!

Translated by