Clear Filters
Clear Filters

working with tall cell array

5 views (last 30 days)
ghattas bisharat
ghattas bisharat on 6 Sep 2023
Answered: Seth Furman on 13 Sep 2023
i have convert table data (three field contains integers or string and the forth field contains 3D matrix) to tall array, I noticed that the forth field is actually tall cell array, and i was wondering what is the right syntax that can be used in order to extract the data and perorm zscore calculations for all the rows of this field?
  2 Comments
ghattas bisharat
ghattas bisharat on 6 Sep 2023
Thanks, i was acually hoping for something that doesn't require a variable assignment that takes up memory(due to the large data sets that i'm working with) because this keeps causing MATLAB to become really slow or even stop working.

Sign in to comment.

Answers (1)

Seth Furman
Seth Furman on 13 Sep 2023
Example for regular cell arrays
C = mat2cell(magic(10),repmat(1,10,1))
C = 10×1 cell array
{[ 92 99 1 8 15 67 74 51 58 40]} {[ 98 80 7 14 16 73 55 57 64 41]} {[ 4 81 88 20 22 54 56 63 70 47]} {[ 85 87 19 21 3 60 62 69 71 28]} {[ 86 93 25 2 9 61 68 75 52 34]} {[ 17 24 76 83 90 42 49 26 33 65]} {[ 23 5 82 89 91 48 30 32 39 66]} {[ 79 6 13 95 97 29 31 38 45 72]} {[ 10 12 94 96 78 35 37 44 46 53]} {[11 18 100 77 84 36 43 50 27 59]}
cellfun(@(x)zscore(x,1),C,UniformOutput=false)
ans = 10×1 cell array
{[ 1.2757 1.4909 -1.5216 -1.3065 -1.0913 0.5072 0.7224 0.0154 0.2306 -0.3228]} {[ 1.6406 1.0189 -1.5025 -1.2607 -1.1916 0.7771 0.1554 0.2245 0.4663 -0.3281]} {[ -1.7789 1.1668 1.4346 -1.1668 -1.0903 0.1339 0.2104 0.4782 0.7460 -0.1339]} {[ 1.2098 1.2799 -1.1046 -1.0345 -1.6656 0.3331 0.4033 0.6487 0.7189 -0.7890]} {[ 1.1779 1.4102 -0.8461 -1.6093 -1.3770 0.3484 0.5807 0.8129 0.0498 -0.5475]} {[-1.3365 -1.0573 1.0174 1.2966 1.5759 -0.3391 -0.0598 -0.9775 -0.6982 0.5785]} {[-0.9673 -1.6004 1.1080 1.3542 1.4246 -0.0879 -0.7211 -0.6507 -0.4045 0.5452]} {[0.9089 -1.4191 -1.1959 1.4191 1.4829 -0.6857 -0.6219 -0.3986 -0.1754 0.6857]} {[-1.4030 -1.3337 1.5070 1.5762 0.9527 -0.5370 -0.4677 -0.2252 -0.1559 0.0866]} {[-1.4159 -1.1650 1.7744 0.9499 1.2008 -0.5198 -0.2688 -0.0179 -0.8424 0.3047]}
Example for tall cell arrays
parpool("Threads");
Starting parallel pool (parpool) using the 'Threads' profile ... Connected to parallel pool with 2 workers.
tC = tall(C)
tC = 10×1 tall cell array {[ 92 99 1 8 15 67 74 51 58 40]} {[ 98 80 7 14 16 73 55 57 64 41]} {[ 4 81 88 20 22 54 56 63 70 47]} {[ 85 87 19 21 3 60 62 69 71 28]} {[ 86 93 25 2 9 61 68 75 52 34]} {[17 24 76 83 90 42 49 26 33 65]} {[ 23 5 82 89 91 48 30 32 39 66]} {[ 79 6 13 95 97 29 31 38 45 72]} : : : : : : : : : : : : : : : : : : : : : :
cellfun(@(x)zscore(x,1),C,UniformOutput=false)
ans = 10×1 cell array
{[ 1.2757 1.4909 -1.5216 -1.3065 -1.0913 0.5072 0.7224 0.0154 0.2306 -0.3228]} {[ 1.6406 1.0189 -1.5025 -1.2607 -1.1916 0.7771 0.1554 0.2245 0.4663 -0.3281]} {[ -1.7789 1.1668 1.4346 -1.1668 -1.0903 0.1339 0.2104 0.4782 0.7460 -0.1339]} {[ 1.2098 1.2799 -1.1046 -1.0345 -1.6656 0.3331 0.4033 0.6487 0.7189 -0.7890]} {[ 1.1779 1.4102 -0.8461 -1.6093 -1.3770 0.3484 0.5807 0.8129 0.0498 -0.5475]} {[-1.3365 -1.0573 1.0174 1.2966 1.5759 -0.3391 -0.0598 -0.9775 -0.6982 0.5785]} {[-0.9673 -1.6004 1.1080 1.3542 1.4246 -0.0879 -0.7211 -0.6507 -0.4045 0.5452]} {[0.9089 -1.4191 -1.1959 1.4191 1.4829 -0.6857 -0.6219 -0.3986 -0.1754 0.6857]} {[-1.4030 -1.3337 1.5070 1.5762 0.9527 -0.5370 -0.4677 -0.2252 -0.1559 0.0866]} {[-1.4159 -1.1650 1.7744 0.9499 1.2008 -0.5198 -0.2688 -0.0179 -0.8424 0.3047]}

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!