Finding value in Matrix to corresponding minvalue Position in different Matrix
Afficher commentaires plus anciens
Dear all,
I am quite new to Matlab and have the following problem:
I do have 2 Matrices A and B with the same size.
I would like to loop over each row of Matrix A to find the Minimum-value and its Column-Position.
Each resulting Column-position should be taken and looped over Matrix B to find the corresponding column-value.
Afterwards, I should receive a matrix in which I will find the values in following order:
minvalue Matrix A row1
corresponding value at position of minvalue row1 of Matrix A
minvalue Matrix A row2
corresponding value at position of minvalue row2 of Matrix A
and so on....
Afterwards, I would like to normalize the resulting Matrix to ensure, I have all values in a range in between -1 and 1
Can anybody please help me out with this?
I thought about this piece of code, but I do not manage to loop over the second Matrix with the minidx1-values to receive the value of the defined value from Matrix A in Matrix B.
for k1=1:size(A,1)
[minval1,minidx1] = min(A(k1,:));
[minval2] = B(:,minidx1:minidx1);
Result{k1}=[minval1,minval2]
end
A=cell2mat(Result)
A=transpose(A)
A=normalize(A)
P.S.: sub2ind is not working, I use R2021b. :(
Many thanks in advance to all those Matlab-cracks out there :)
3 commentaires
Bruno Luong
le 27 Sep 2023
Modifié(e) : Bruno Luong
le 27 Sep 2023
"I am quite new to Matlab"
You posted a MATLAB question in 2017. How come you are still new to MATLAB six year later?
Alexander Hummel
le 6 Oct 2023
Bruno Luong
le 6 Oct 2023
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!