Finding minimum value by using min()
Show older comments
I want to find minimum 10 value
i wrote
for j= 1:10
for i= 1:10
for k = 1:13
fitness (j,i,k)=(........);%10*10*13 double
end
end
minfit(j) = min(fitness(j,:));
end
disp (minfit);
in min function it is unable to find
minimum value of .
please helpme i am not able to solfitnesse
Accepted Answer
More Answers (1)
madhan ravi
on 7 Dec 2018
Edited: madhan ravi
on 7 Dec 2018
minFit=squeeze(min(Ofitness,[],[1 2])).'
minFit=squeeze(min(min(Ofitness))).' % in older versions of matlab thank you sir Walter
32 Comments
Sushree Patra
on 7 Dec 2018
Sushree Patra
on 7 Dec 2018
madhan ravi
on 7 Dec 2018
attach fitness as .mat file
Sushree Patra
on 7 Dec 2018
Jan
on 7 Dec 2018
@Sushree Patra: Please post the code. It is strange, that you get two different errors. Without seeing the code, it is impossible to fix it.
madhan ravi
on 7 Dec 2018
I just ran your code but I didn't get any errors?
Sushree Patra
on 7 Dec 2018
madhan ravi
on 7 Dec 2018
REmove this section of the code!:
for j=1:10
for i =1:10
for k = 1:13
Ofitness(j,i,k)= (c*opo_pop(j,i)*1)+(c*(OEts(k,j,i)*1+OEf_total(j,i,1)*1))+(c*sqrt((distances(k,opo_pop(j,i))-d0).^2))+(c*1);
end
end
OminFit(j) = min(Ofitness(j,:));
end
Sushree Patra
on 7 Dec 2018
madhan ravi
on 7 Dec 2018
wierd this is what i got:
>> minFit
minFit(:,:,1) =
14831476.9829354
minFit(:,:,2) =
52886274.7233204
minFit(:,:,3) =
20688650.8562262
minFit(:,:,4) =
53651138.6228232
minFit(:,:,5) =
7829219.62925941
minFit(:,:,6) =
18287522.4496381
minFit(:,:,7) =
10960447.7077643
minFit(:,:,8) =
27724536.6404127
minFit(:,:,9) =
19579242.1922717
minFit(:,:,10) =
29888312.5238552
minFit(:,:,11) =
24860479.583199
minFit(:,:,12) =
31616660.2405204
minFit(:,:,13) =
47582942.7897235
>>
Sushree Patra
on 7 Dec 2018
Sushree Patra
on 7 Dec 2018
madhan ravi
on 7 Dec 2018
Ofitness is a 3D matrix , which minimum do you want to return? minimum of each row/column or the minimum of each page?
Sushree Patra
on 7 Dec 2018
Sushree Patra
on 7 Dec 2018
madhan ravi
on 7 Dec 2018
min(Ofitness) % that's it outside loop
Sushree Patra
on 7 Dec 2018
Sushree Patra
on 7 Dec 2018
Sushree Patra
on 7 Dec 2018
madhan ravi
on 7 Dec 2018
Edited: madhan ravi
on 7 Dec 2018
minFit=squeeze(min(Ofitness,[],[1 2])).' % after this I don't have any clue what you want
Walter Roberson
on 7 Dec 2018
madhan, the syntax min(Array,[],[vector]) is new as of r2018b .
madhan ravi
on 7 Dec 2018
Thank you so much sir Walter , is there any alternatives for it in older versions?
Walter Roberson
on 7 Dec 2018
multiple min calls or reshape followed by min
madhan ravi
on 7 Dec 2018
Thank you sir Walter ?
Sushree Patra
on 7 Dec 2018
Sushree Patra
on 7 Dec 2018
madhan ravi
on 7 Dec 2018
forget about everything demonstrate a neat and clean example with 2 by 2 matrix with 2 pages with your desired result it'll save time and avoid confusions
Sushree Patra
on 7 Dec 2018
Edited: Sushree Patra
on 7 Dec 2018
madhan ravi
on 7 Dec 2018
what does A' and B' represent? the pages?
Sushree Patra
on 7 Dec 2018
madhan ravi
on 7 Dec 2018
A(:,:,1)=[1,5;6,2];
A(:,:,2)=[9,5;3,6];
B(:,:,1)=[9,2;6,3];
B(:,:,2)=[7,3;8,4];
result=[min(A(:)) min(B(:))]
Sushree Patra
on 7 Dec 2018
Categories
Find more on Problem-Based Optimization Setup in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!