Need to store some results of a function in a matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
for a=4:5
[A]=correlacion(v7(a).imagen,v3(i).imagen)
end
And this is the function that I'm using
function [A]=correlacion(Ipat, Iref)
for i=1:20
% Trobar la correlacio normalitzada entre el patro i la imatge de referencia:
Icorr = normxcorr2(Ipat,Iref);
[posY, posX] = find(abs(Icorr) == max(max(Icorr)));
% Correccio de la posicio fent servir la mida del patro:
posXreal= posX - (size(Ipat,2)-1)/2;
posYreal= posY - (size(Ipat,1)-1)/2;
A(i,:)=[posXreal' posYreal'];
end
end
The idea is to store the results in a matrix A, but the program forget the numbers that has created.
0 Kommentare
Antworten (1)
Matthew Eicholtz
am 31 Mai 2017
If I understand your problem correctly, the values stored in A when a=4 are being replaced by the new values generated by your function when a=5. There are many potential remedies to this problem. One solution might be to use separate variables for each value of a:
A4 = correlacion(v7(4).imagen,v3(i).imagen);
A5 = correlacion(v7(5).imagen,v3(i).imagen);
This works well when a=4:5, but maybe not if a had more values. Suppose a=1:100; then I would suggest trying a cell array:
A = cell(100,1);
for a=1:100
A{a} = correlacion(v7(a).imagen,v3(i).imagen)
end
Siehe auch
Kategorien
Mehr zu Variables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!