user1673206
user1673206

Reputation: 1711

Average of two dimensional array

I have one dimensional array and i need to calculate it's average.

I tried:

A = mean(mean(PSNRarr,2),2)

but I get an error.

If someone knows how to make it work it will be great!

Upvotes: 3

Views: 1800

Answers (2)

High Performance Mark
High Performance Mark

Reputation: 78354

Try

mean(mean(PSNRarr))

more characters to get over SO minimum.

Upvotes: 4

Dennis Jaheruddin
Dennis Jaheruddin

Reputation: 21563

The easiest way that works for any amount of dimensions (assuming it is a regular matrix):

 mean(PSNRarr(:))

However, if you have a cell array with numbers, try:

mean(mean(cell2mat(PSNRarr)))

Upvotes: 5

Related Questions