How to get data from a different array that created from same function

I have a data of
Position (DE,ER,OT)
13.0358109633153 7.29645405403526 1.93185356261591
11.6734834559360 1.24957327651606 0.382506369952874
19.5973279571221 2.91975489592012 3.01537406416702
19.2470045171241 1.93920480774493 1.04589509828743
6.89871768243832 9.33568916859900 2.01427092942622
5.53701248919927 1.60427609048376 2.04583332944291
7.55697709232973 1.39803559972575 2.23169951768857
1.92111202753096 6.18480688432816 0.153797552224977
11.5078816269411 7.91832559445504 1.25329718843926
9.01559229793461 5.73664601452083 0.400867067225150
Fitness
9.28064574272322
320.350630350650
5.88518035366886
11.7141376654576
8.83060849143833
5.13276803550592
5.40442492637360
2564.77531252141
18.0403993923121
472.153376001588
I try to calculate the best poisition that have the best Fitness
I use Fbest=min(Fitness) to get the best fitness from the data but i could not automaticly get the position. I know that the best fitness is 5.1327 which mean the best position is the data number 6 from data of position
How do I get the best position automaticly when I get the best Fitness ?
here are my initialization code
clc;
tic
UkPop = 30; % Size of The Population
A_loud = 0.5; % Loudness
r_ratio = 0.6; % Pulse rate
alpha = 0.9; % Alpha
gamma = alpha; % Gamma
Frek_min = 0; % Minimum freq
Frek_max = 5; % Maksimum freq
It = 1 % Iteration
MaxIt = 10 % Max Iteration
Dimensi = 3; % Dimension Parameter That will be Optimized
Frek_Bat = zeros(UkPop,1); % Frequency
Kecepatan = zeros(UkPop,Dimensi); % Velocity
Konstraint =[20 10 5 % Maximum
0.1 0.1 0.1]; % Minimum
for ix = 1:UkPop,
for is = 1:Dimensi
Bat_Position(ix,is) = Konstraint(2,is)+rand*(Konstraint(1,is)-Konstraint(2,is));
end
ER = Bat_Position(ix,1);
DE = Bat_Position(ix,2);
OT = Bat_Position(ix,3);
sim('Outer_control');
t=ScopeDatabat.time;
y=ScopeDatabat.signals.values;
for i=1:1001
error(i)=abs(y(i)^2)*t(i);
end
ITAE=sum(error);
Fitness(ix,:)=ITAE;
ITAE
ix
end
% Best
[Fitness_Min,Indeks] = min(Fitness);
posisi_terbaik_Bat = Bat_Position(Indeks,:);

2 件のコメント

Davide Masiello
Davide Masiello 2022 年 10 月 10 日
This 2 lines of code
[Fitness_Min,Indeks] = min(Fitness);
posisi_terbaik_Bat = Bat_Position(Indeks,:);
should do exactly what you are looking for.
Are they not?
Dicky Nafis
Dicky Nafis 2022 年 10 月 10 日
Thank you. yeah it works I have re check it , acctualy i think my next script is the cause for the error

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCurve Fitting Toolbox についてさらに検索

タグ

質問済み:

2022 年 10 月 10 日

コメント済み:

2022 年 10 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by