Running a loop through an array of matrices

OK...now here is the second part of the thing...!
I have two arrays of size (576*576*2) and (576*576*5)....one containing 2 matrices of images that were 576*576 and the other containing 5 similar images. For each matrix in the first array, I need to calculate the matrix in the other array that has the lowest mean error. How do I exactly do that? I sorta have the loops figured out!
This is how my code looks for one value of the first TEST array..
min=100*sum(576*1); for i=1:4
if sum(testa(:,:,1)-traina(:,:,i))<min min=(sum(testa(:,:,1)-traina(:,:,i))) disp(val) val=i end end disp(val)
However, it turns out that val is not changing after the first case. It always gives me the answer as 1, when it should give me an answer three for testa(:,:,2). Both arrays contain
M-B*A*B' where A is the imread of the image and B is its dct2 value.
THanks a lot you guys!

답변 (1개)

the cyclist
the cyclist 2011년 8월 5일

0 개 추천

In your if statement, that sum(...) is going to result in a vector of length 576, because it is going to sum your array down each column. Instead, try using sum(sum(...)) there.

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

질문:

2011년 8월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by