필터 지우기
필터 지우기

Matrix of ratios w.r.t. row or colum header

조회 수: 1 (최근 30일)
Muhammad Shafique
Muhammad Shafique 2013년 3월 9일
I have very large symmetric matrices in which first row and column are headers that represent the size of different groups and the vertices represent the number of common members between each pair of groups. For example, the original 5*5 matrix is as follows:
A=[100 80 90 50 70; 80 80 30 40 10; 90 30 90 10 50; 50 40 10 50 30; 70 10 50 30 70]
I need to calculate a ratio matrix so that each element of the original matrix is divided by its respective row or column header, whichever is smaller of the two. That is, the resulting ratio matrix will be obtained as following:
Ar=[100 80 90 50 70; 80 80/80 30/80 40/50 10/70; 90 30/80 90/90 10/50 50/70; 50 40/50 10/50 50/50 30/50; 70 10/70 50/70 30/50 70/70]
Could anyone help how can it be done? I shall be grateful.
Best regards, shafique

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 9일
편집: Azzi Abdelmalek 2013년 3월 9일
n=size(A,2)
out=A./[ones(1,n);repmat([1 A(1,2:end)],n-1,1)]

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by