# how to calculate the average for each row of cell array

39 views (last 30 days)
mohammad albajah on 27 Dec 2020
Commented: mohammad albajah on 28 Dec 2020
i have R = cell(13,21);
and i want to calculate the average (mean) value for each row in it
i tried too much but i didn't reach to solution
can someone help me?
R =
13×21 cell array
Columns 1 through 10
{[ 8.1759]} {[ -14.1538]} {[ -1.8647]} {[ 72.3241]} {[ 6.9314]} {[ 10.5537]} {[-10.3345]} {[ -1.3615]} {[ 52.8081]} {[ 5.0610]}
{[-100.5301]} {[-1.6989e+03]} {[ 192.9444]} {[ 19.3296]} {[ 11.8006]} {[ 296.5130]} {[350.4125]} {[ -39.7964]} {[ -3.9869]} {[ -2.4340]}
{[-155.8834]} {[ -34.5291]} {[ -677.4341]} {[ -425.0164]} {[ 28.8625]} {[ -56.2095]} {[ 9.4250]} {[ 184.9113]} {[ 116.0118]} {[ -7.8783]}
{[ -18.0834]} {[ 9.8230]} {[ -24.0222]} {[ -33.9759]} {[ 4.2114]} {[ 4.4252]} {[-34.2615]} {[ 83.7867]} {[ 118.5041]} {[-14.6888]}
{[ -87.9303]} {[ -19.5714]} {[ 36.0203]} {[ -114.0915]} {[ -7.6822]} {[ 230.0494]} {[ 16.0614]} {[ -29.5602]} {[ 93.6296]} {[ 6.3044]}
{[ 6.0727]} {[ -118.6314]} {[ 4.9112]} {[ -109.1580]} {[-29.8590]} {[ 179.8185]} {[-90.4604]} {[ 3.7449]} {[ -83.2366]} {[-22.7685]}
{[ -40.9789]} {[ -433.8480]} {[ -20.3578]} {[ -185.8036]} {[-13.6742]} {[ 103.4759]} {[161.0548]} {[ 7.5573]} {[ 68.9748]} {[ 5.0762]}
{[-201.7300]} {[ 269.7178]} {[1.2505e+03]} {[ 213.1745]} {[ 47.6268]} {[-251.3046]} {[-60.8768]} {[-282.2525]} {[ -48.1147]} {[-10.7496]}
{[ 237.9048]} {[ -162.3893]} {[1.8802e+03]} {[-1.1589e+03]} {[723.5503]} {[ 359.4810]} {[-28.4219]} {[ 329.0747]} {[-202.8294]} {[126.6382]}
{[-902.9213]} {[ -45.4595]} {[ -65.6897]} {[ 1.2032e+03]} {[ 19.8824]} {[-916.3035]} {[ 18.8131]} {[ 27.1853]} {[-497.9192]} {[ -8.2282]}
{[ 44.7339]} {[ 37.7313]} {[ 78.4548]} {[ 5.1115]} {[ 48.9383]} {[-227.7321]} {[ 23.0677]} {[ 47.9647]} {[ 3.1250]} {[ 29.9193]}
{[-113.5685]} {[ -60.9937]} {[ -257.7253]} {[ 282.8172]} {[ 1.6673]} {[ 123.9788]} {[ 22.1870]} {[ 93.7496]} {[-102.8770]} {[ -0.6065]}
{[ -36.2473]} {[ -79.2892]} {[ 34.1592]} {[ -25.5460]} {[-23.3429]} {[ -33.5835]} {[144.1470]} {[ -62.1011]} {[ 46.4425]} {[ 42.4371]}
Columns 11 through 19
{[ 7.7059]} {[ 2.3570]} {[ -91.4193]} {[ -8.7614]} {[ -13.3402]} {[ -12.0441]} {[ -1.1543]} {[ -1.7575]} {[ 44.7697]}
{[ -61.1583]} {[-672.5359]} {[ -67.3762]} {[-41.1326]} {[-1.0335e+03]} {[ 7.6519]} {[ 4.6714]} {[ 117.3792]} {[ 0.4680]}
{[ 15.3428]} {[ 40.9589]} {[ 25.6973]} {[ -1.7451]} {[ 3.3985]} {[ 504.1610]} {[ -34.2371]} {[ 66.6766]} {[ -21.4801]}
{[ -15.4346]} {[ -45.5135]} {[ -64.3722]} {[ 7.9791]} {[ 8.3842]} {[ 157.4226]} {[ -19.5128]} {[ -20.5035]} {[ -27.5981]}
{[-188.7908]} {[ -6.5795]} {[ 20.8400]} {[ 1.4032]} {[ -42.0209]} {[ -38.3550]} {[ -2.5826]} {[ 77.3374]} {[ 8.1801]}
{[ 137.1177]} {[ -73.1581]} {[1.6261e+03]} {[444.7896]} {[-2.6786e+03]} {[ -67.3160]} {[ -18.4136]} {[ 110.8912]} {[ 409.2705]}
{[ -38.4127]} {[ 80.0101]} {[ 730.2441]} {[ 53.7421]} {[ -406.6802]} {[ 34.2658]} {[ 2.5218]} {[ -19.0830]} {[ 23.0161]}
{[ 56.7209]} {[ 377.3784]} {[ 64.3305]} {[ 14.3725]} {[ -75.8372]} {[ 298.2654]} {[ 66.6375]} {[-351.6154]} {[ 11.3595]}
{[ 62.9176]} {[-224.6201]} {[ 138.4475]} {[-86.4408]} {[ -42.9463]} {[-1.6030e+03]} {[1.0008e+03]} {[ 497.2414]} {[-616.8740]}
{[ 379.2066]} {[ 1.3687]} {[ -25.0688]} {[ -0.4143]} {[ 19.0920]} {[ -36.2248]} {[ -0.5986]} {[ 27.5882]} {[ 10.9642]}
{[-139.2281]} {[ 40.4564]} {[ 2.6358]} {[ 25.2358]} {[ -117.4336]} {[ 5.4807]} {[ 52.4728]} {[-244.1797]} {[ 3.4187]}
{[ -45.0983]} {[ 50.3497]} {[ -55.2517]} {[ -0.3257]} {[ -24.2207]} {[ -233.4627]} {[ -1.3763]} {[-102.3433]} {[ 1.5103]}
{[ 61.0545]} {[-135.8434]} {[ 101.5907]} {[ 92.8292]} {[ 133.5539]} {[ -43.7671]} {[ -39.9925]} {[ -57.5374]} {[ 29.9085]}
Columns 20 through 21
{[ 68.1667]} {[ 6.5329]}
{[ 11.7593]} {[ 7.1790]}
{[ 41.8323]} {[ -2.8408]}
{[ -28.9992]} {[ 3.5945]}
{[ -244.9604]} {[ -16.4941]}
{[-2.4647e+03]} {[-674.2008]}
{[ -174.1685]} {[ -12.8179]}
{[ -59.9388]} {[ -13.3913]}
{[ -306.4811]} {[ 191.3539]}
{[ -505.2989]} {[ -8.3502]}
{[ -15.9090]} {[-152.3137]}
{[ 112.3073]} {[ 0.6621]}
{[ 43.0295]} {[ 39.3185]}
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

Ameer Hamza on 27 Dec 2020
First use cell2mat() and then apply mean() along rows
R_mean = mean(cell2mat(R), 2)
##### 1 CommentShowHide None
mohammad albajah on 28 Dec 2020
it works, thank you

Sign in to comment.

### Categories

Find more on Cell Arrays in Help Center and File Exchange

R2020b

### Community Treasure Hunt

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

Start Hunting!