Adding elements of a matrix

3 ビュー (過去 30 日間)
hasan alhussaini
hasan alhussaini 2018 年 4 月 3 日
編集済み: KL 2018 年 4 月 3 日
Hi, I've attached an image of a variable i have. the variable F is a 5x22 cell, each element in the cell is a 1x3 containing RGB numbers. is there a way to make F the average of all those elements?
* adding the first column and averaging it to make Red pixels
* adding the second column and averaging it to make green pixels
* adding the third column and averaging it to make blue pixels

回答 (2 件)

KSSV
KSSV 2018 年 4 月 3 日
K = cell(2,3) ;
for i = 1:2
for j = 1:3
K{i,j} = rand(3,1) ;
end
end
iwant = cellfun(@mean,K)
Or you can run a loop too.

KL
KL 2018 年 4 月 3 日
編集済み: KL 2018 年 4 月 3 日
I'm not entirely sure what you want but if you want to calculate mean of all the RGB numbers and have 1x3 result,
mean(cell2mat(F(:)))

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by