필터 지우기
필터 지우기

calculate values from different matrices

조회 수: 1 (최근 30일)
babis
babis 2014년 5월 28일
답변: Roger Wohlwend 2014년 5월 28일
I have a matrix U (n*v). I want for every column to have a matrix that has the number of the non-zero rows. For example U= [1 1 0; 2 0 2; 4 3 0; 4 0 0; 0 5 1; 3 1 3; 1 0 5; 0 2 1] will return for v1=1 [1 2 3 4 6 7], v2=2 [1 3 5 6 8], v3=3 [2 5 6 7 8]. Then, we have another matrix K (n*n) and we want for every new matrix we created before(v1 v2 v3) , to take the 5 nearest to zero values. for example [0.1 0.5 0.2 0.25 0.3 -0.1 0.4 0.35; 0.3 0.3 0.2 0.25 0.3 -0.1 0.4 0.35; 0.15 0.5 0.4 0.25 0.3 -0.1 0.4 0.35; -0.4 0.5 0.2 0.6 0.3 -0.1 0.4 0.35; 0.3 0.5 0.2 0.25 0.12 -0.1 0.4 0.35; 0.15 0.5 0.2 0.25 0.3 -0.1 0.4 0.35; 0.3 0.5 0.2 0.25 0.3 -0.1 0.213 0.35; 0.125 0.5 0.2 0.25 0.3 -0.1 0.4 0.12]
for row 1 is [1 3 4 6 7]
then, we want to create a new matrix A where every element is the sum of each absolute value of K multiplied with the respective values of U, and the sum will be divided by the sum of the 5 absolute values from K. For example: A(1,1)= {1*0.1+4*0.2+4*0.25+3*|-0.1|+1*0.4}/(0.1+0.2+0.25+|-0.1|+0.4)

채택된 답변

Roger Wohlwend
Roger Wohlwend 2014년 5월 28일
Task 1:
m = size(U,2);
v = cell(m,1);
for k = 1 : m
v{k} = find(U(:,k) > 0);
end
Task 2: I don't understand what you want to do. v1, v2 and v3 are vectors of different lengths. How do you use them on the matrix K?

추가 답변 (0개)

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by