Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Assume we have a 3 dimensional array F and 2 dimensional matrix S. First I find a matrix Y which is F multiplied by S. Then I try to find an estimate of F (lets call it F_est) from Y as sanity check in my code. Can anyone see a flaw in logic, I dont seem to know why F_est is not exactly F.

F= randn(2,4,600);
S= randn(4,600);
for i =1:size(F,1);
    for j=1:size(F,2)
        for k= 1:size(F,3)
            Y(i,k)= F(i,j,k) * S(j,k);
        end
    end
end

for i =1:size(F,1)
    for j=1:size(F,2)
        for k= 1:size(F,3)
            F_est(i,j,k)= Y(i,k) / S(j,k);
        end
    end
end

then I try to see if F_est - F is zero and it is not. Any ideas. Much aprreciated.

**** EDIT after comments

Based on the answers I got I am wondering if the code below makes any sense?

for k=1:size(F,3)
Y(:,k) = squeeze(F(:,:,k)* S(:,k)
end

Am I able to recover F if I have Y and S?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
140 views
Welcome To Ask or Share your Answers For Others

1 Answer

When you create Y, you are replacing its values continuously. For any value of pair of i,k you are overwriting Y jtimes!

Those 2 codes are not equivalent, as F_est(i,j,k) computed only once, but you have Y(i,k) j times.

I don't know what you are trying to do, but a multiplication of a 3D matrix by a 2D matrix is not defined, and its not a 2D matrix


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...