フィルターのクリア

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 Center および File ExchangeInterpolation についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by