save elements in a structure with matalb ?
Mostrar comentarios más antiguos
Hello, I have a 3x4 matrix, I want to implement this algorithm:
for each ligne compute the max value
store elements with value >= max/2 (for each ligne)
save this elements and correspending indices (i,j)
what I did is this :
%Filtrer les mauvaises correspondences en se basant sur la mesure de
%similarité.
i = 1;
for indVertexS = 1 : size(C,1)
maxi = max(C(indVertexS,:));
maxi = maxi/2;
j = 1;
for indVertexM = 1 : size(C,2)
if C(indVertexS,indVertexM) >= maxi
Cnew(i).corresp(j)= C(indVertexS,indVertexM);
Cnew(i).indS(j) = indVertexS ;
Cnew(i).indM(j) = indVertexM;
else
continue;
end
j = j+1;
end
i = i+1;
end
But the problem I encountered is that it includes incorrect values to (zeroes). and some indices are also incorrect (I get zeroes), and I don't understand where the error is ?
2 comentarios
jiji hr
el 20 de Jun. de 2016
Shameer Parmar
el 20 de Jun. de 2016
It working fine with me..
my input was C = [1 5 3; 5 4 2; 7 8 3];
and Output was:
>> Cnew
Cnew =
1x3 struct array with fields:
corresp
indS
indM
>> Cnew(1)
ans =
corresp: [5 3]
indS: [1 1]
indM: [2 3]
>> Cnew(2)
ans =
corresp: [5 4]
indS: [2 2]
indM: [1 2]
>> Cnew(3)
ans =
corresp: [7 8]
indS: [3 3]
indM: [1 2]
Respuestas (0)
Categorías
Más información sobre Time Series Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!