Borrar filtros
Borrar filtros

calculate values from different matrices

1 visualización (últimos 30 días)
babis
babis el 28 de Mayo de 2014
Respondida: Roger Wohlwend el 28 de Mayo de 2014
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)

Respuesta aceptada

Roger Wohlwend
Roger Wohlwend el 28 de Mayo de 2014
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?

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by