How i can generate a random low rank EDM matrix X such that X=A*B and A of size (n,r), and B of size(r,n)

Réponses (1)

Image Analyst
Image Analyst le 3 Avr 2023

0 votes

I'm not sure what that means, but you can generate an EDM matrix with bwdist

3 commentaires

i mean like the following code , however this give me EDM matrix but i want this marix exactly to be a result of the multiplication of two matrices A in size n*r and B of size r*n
Y = randn(n, r);
% Compute the Euclidean distance matrix (EDM) between points
X = zeros(n, n);
for i = 1:n
for j = i:n
dist = sqrt(sum((Y(i,:) - Y(j,:)).^2));
X(i,j) = dist;
X(j,i) = dist;
end
end
% Verify that X is a valid EDM
valid = true;
for i = 1:n
for j = i:n
if i == j && X(i,j) ~= 0
valid = false;
break;
elseif X(i,j) ~= X(j,i) || X(i,j) < 0
valid = false;
break;
end
end
end
if valid
disp('X is a valid EDM');
else
disp('X is not a valid EDM');
end
Hajar Alshaikh
Hajar Alshaikh le 4 Avr 2023
You can notice here that X is EDM . However, it is not a low rank matrix . The rank of this X is n-1 which is not a low rank
Image Analyst
Image Analyst le 4 Avr 2023
You're using EDM in a way that is not familiar to me, as a member of the image processing community, where it means the distance of a pixel in a foreground object to the nearest background pixel.
Your first loop looks like it's doing the same thing as pdist2
Sorry I can't help you because I don't understand why rank matters and why you want it to be a low number. Image image processing, the EDM is what it is - it's a given for a given matrix and is not something you can adjust. It's like saying the distance between 10 and 15 is 5. OK, it's 5 but you can't say that want it to be 4. It just isn't. So that's why I say I don't understand what you want or why you want it.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Deep Learning Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by