# How to find the index value of an element in a cell array?

4 vues (au cours des 30 derniers jours)
Anibal Marrero le 13 Mar 2023
Hello,
I have tried by all means finding an example for my case but I only got frustration, so I hope you can help me.
Context: I am using a Differential Evolution Algorithm and as a part of the results I calculate the mean, sd and also the best OF value (in this case, the minimum value) of each generation (iteration). I run the algorithm 6 times and I obtain 6 data.txt files (runde*.txt) containing the following information: iteration, OF value, parameters values (2 params.) and the run number (i.e., if it is the 1st, 2nd, 3rd etc run). Each file contains 5 columns (named before) and 50 rows. This is the code I am using:
files = dir('runde*.txt');
n=length(files);
for i = 1:n
filename = sprintf('runde%d.txt', i);
dedata{i} = importdata(filename);
end
m=length(dedata{i}.data);
fileSTATS=fopen('destats.txt', 'w');
MOF=[]; % matrix in which columns contain best OF values (S_bestval.FVr_oa)...
...per generation of every run
for j=1:m
for i=1:n
MOF(j,i)=dedata{1,i}.data(j,2);
mean_MOF(j,1)=mean(MOF(j,:));
sd_MOF(j,1)=std(MOF(j,:));
best_MOF(j,1)=min(MOF(j,:));
end
fprintf(1,'Gen.: %d,\t mean: %.6e,\t SD: %.6e,\t best: %.6e\n',j,mean_MOF(j),sd_MOF(j),best_MOF(j));
fprintf(fileSTATS,'%d\t %e\t %e\t %e\r\n',j,mean_MOF(j),sd_MOF(j),best_MOF(j));
end
fclose(fileSTATS);
MOF stores the OF values of every file (which are in column 2).
My goal is to store (besides the data indicated in the code) in the file destats.txt the data (OF parameters and run number) associated to each value of the vector best_MOF (a vector which collects the best OF value of every generation off all runs of the algorithm).
I suspect it is a question of finding the position of every best_MOF(j,1) and indicating the data to store according to the index of every element best_MOF(j,1). That is the reason for the question. I don't know if it the correct question for this problem. I hope as well I have explained my problem clearly.
I include files in case they are needed. Note (Ed.): As I explained above, the goal is to write next to best_MOF column in destats.txt file the corresponding values in runde*.txt files. Note that the array best_MOF(j,1) does not operate values, it only selects the minimun value of the 2nd column of all six runde*.txt files row by row. Therefore, the 5th, 6th and 7th columns of destats.txt will be the so-named corresponding values of 3rd, 4th and 5th columns of runde*.txt files.
I truly appreciate any advise or solution for this problem. I have little experience with programming.
Thank you very much.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Adam Drake le 13 Mar 2023
Modifié(e) : Adam Drake le 13 Mar 2023
Had to do quite a bit of imagining without the starting data files, but I think this will set you straight. Let me know if you have questions or if it doesn't work.
EDIT: fixed case where length of data set in runde*.txt files are different for each file. Console shows dataset length but it is not ouput to file. Easily added if needed. Add attached "runde7.txt" to directory and run to see functionality. runde7 has 52 rows instead of 50. Note that MOF will contain "NaN" on files with datasets less than max(len). Account for NaN's with 'omitnan' flag on mean, std, and min functions.
EDIT2: Added best parameters to console and file output
clc, clear all
files = dir('runde*.txt');
n = length(files);
for i = 1:n
filename = sprintf('runde%d.txt', i);
dedata{i} = importdata(filename);
len(i) = length(dedata{i}.data);
end
m = max(len);
MOF = nan(n,m); % matrix in which columns contain best OF values (S_bestval.FVr_oa)...
...per generation of every run
for i = 1:n % number of files
for j = 1:len(i) % length of data
MOF(i,j)=dedata{i}.data(j,2); % OF Values stored in column 2 of data
end
end
mean_MOF = mean(MOF,1,'omitnan'); % row vector with mean of each column (run)
sd_MOF = std(MOF,0,1,'omitnan'); % row vector with std of each column (run)
[best_MOF,best_idx] = min(MOF,[],1,'omitnan'); % row vector with min of each column (run)
p1 = zeros(1,m);
p2 = zeros(1,m);
run = zeros(1,m);
fileSTATS=fopen('destats.txt', 'w');
for j = 1:m
p1(j) = dedata{best_idx(j)}.data(j,3);
p2(j) = dedata{best_idx(j)}.data(j,4);
run(j) = dedata{best_idx(j)}.data(j,5);
fprintf(1,'Gen.: %d,\tmean: %.6e,\tSD: %.6e,\tBest: %.6e,\tp1: %.6e\tp2: %.6e\trun: %d\n', ...
j,mean_MOF(j),sd_MOF(j),best_MOF(j),p1(j),p2(j),run(j));
fprintf(fileSTATS,'%d\t %e\t %e\t %e\t %e\t %e\t %d\r\n', ...
j,mean_MOF(j),sd_MOF(j),best_MOF(j),p1(j),p2(j),run(j));
end
Gen.: 1, mean: 1.777127e+00, SD: 7.709961e-01, Best: 6.468260e-01, p1: -5.762191e-02 p2: -1.120718e+00 run: 6 Gen.: 2, mean: 1.391021e+00, SD: 6.838437e-01, Best: 5.943482e-01, p1: 1.074498e+00 p2: -3.054331e+00 run: 6 Gen.: 3, mean: 9.805492e-01, SD: 6.692086e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 4, mean: 9.805492e-01, SD: 6.692086e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 5, mean: 9.089068e-01, SD: 5.807616e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 6, mean: 9.089068e-01, SD: 5.807616e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 7, mean: 7.496810e-01, SD: 5.243635e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 8, mean: 7.496810e-01, SD: 5.243635e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 9, mean: 6.828632e-01, SD: 4.422585e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 10, mean: 5.668665e-01, SD: 4.279609e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 11, mean: 5.668665e-01, SD: 4.279609e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 12, mean: 5.668665e-01, SD: 4.279609e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 13, mean: 4.932501e-01, SD: 4.334705e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 14, mean: 4.347951e-01, SD: 2.915590e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 15, mean: 4.347951e-01, SD: 2.915590e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 16, mean: 4.347951e-01, SD: 2.915590e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 17, mean: 4.347951e-01, SD: 2.915590e-01, Best: 2.453411e-01, p1: -3.071395e+00 p2: -1.000331e+01 run: 2 Gen.: 18, mean: 4.140266e-01, SD: 3.049505e-01, Best: 2.018446e-01, p1: 8.605031e-02 p2: -2.182238e-02 run: 4 Gen.: 19, mean: 3.720139e-01, SD: 3.401474e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 20, mean: 3.701877e-01, SD: 3.400666e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 21, mean: 3.701877e-01, SD: 3.400666e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 22, mean: 3.175751e-01, SD: 2.234774e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 23, mean: 3.175751e-01, SD: 2.234774e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 24, mean: 3.175751e-01, SD: 2.234774e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 25, mean: 3.175751e-01, SD: 2.234774e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 26, mean: 3.175751e-01, SD: 2.234774e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 27, mean: 2.435447e-01, SD: 1.174528e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 28, mean: 2.435447e-01, SD: 1.174528e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 29, mean: 2.435447e-01, SD: 1.174528e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 30, mean: 2.435447e-01, SD: 1.174528e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 31, mean: 2.372693e-01, SD: 1.183402e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 32, mean: 2.344517e-01, SD: 1.158099e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 33, mean: 2.344517e-01, SD: 1.158099e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 34, mean: 2.344517e-01, SD: 1.158099e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 35, mean: 2.237176e-01, SD: 1.222427e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 36, mean: 2.237176e-01, SD: 1.222427e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 37, mean: 2.237176e-01, SD: 1.222427e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 38, mean: 2.211849e-01, SD: 1.201115e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 39, mean: 2.211849e-01, SD: 1.201115e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 40, mean: 2.211849e-01, SD: 1.201115e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 41, mean: 2.211849e-01, SD: 1.201115e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 42, mean: 2.051711e-01, SD: 1.137674e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 43, mean: 2.051711e-01, SD: 1.137674e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 44, mean: 2.051711e-01, SD: 1.137674e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 45, mean: 2.051711e-01, SD: 1.137674e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 46, mean: 2.051711e-01, SD: 1.137674e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 47, mean: 1.963109e-01, SD: 1.105632e-01, Best: 4.179763e-02, p1: 9.760521e-01 p2: -1.021824e+00 run: 1 Gen.: 48, mean: 1.884904e-01, SD: 1.170291e-01, Best: 1.857550e-02, p1: 9.822058e-01 p2: -9.849300e-01 run: 1 Gen.: 49, mean: 1.872204e-01, SD: 1.168202e-01, Best: 1.857550e-02, p1: 9.822058e-01 p2: -9.849300e-01 run: 1 Gen.: 50, mean: 1.872204e-01, SD: 1.168202e-01, Best: 1.857550e-02, p1: 9.822058e-01 p2: -9.849300e-01 run: 1
fclose(fileSTATS);
##### 17 commentairesAfficher 15 commentaires plus anciensMasquer 15 commentaires plus anciens
Adam Drake le 14 Mar 2023
You're trying to do mean and std and min before you've fully populated MOF. you have to finish that loop first. Please accept my answer.
clc, clear all
files = dir('runde*.txt');
n = length(files);
for i = 1:n
filename = sprintf('runde%d.txt', i);
dedata{i} = importdata(filename);
len(i) = length(dedata{i}.data);
end
m = length(dedata{i}.data);
MOF = []; % matrix in which columns contain best OF values (S_bestval.FVr_oa)...
...per generation of every run
% YOU HAVE TO ALLOCATE MOF WITH VALUES BEFORE YOU CAN TAKE THE MEAN,STD,MIN
for i = 1:n % number of files
for j = 1:len(i) % length of data
MOF(i,j)=dedata{i}.data(j,2); % OF Values stored in column 2 of data
end
end
mean_MOF = mean(MOF); % row vector with mean of each column (run)
sd_MOF = std(MOF); % row vector with std of each column (run)
[best_MOF,best_idx] = min(MOF); % row vector with min of each column (run)
fileSTATS=fopen('destats.txt', 'w');
for j = 1:m
best_params(j,:) = dedata{best_idx(j)}.data(j,3:end-1);
best_run(j) = dedata{best_idx(j)}.data(j,end);
fprintf(1,'Gen.: %d,\tmean: %.6e,\tSD: %.6e,\tBest: %.6e,\t',...
j,mean_MOF(j),sd_MOF(j),best_MOF(j));
fprintf(1,'Parameters:\t');
for k = 1:size(best_params,2) % 2 specifies number of columns
fprintf(1,'%.6e\t',best_params(j,k));
end
fprintf(1,'Run:\t%d\r\n',best_run(j))
fprintf(fileSTATS,'%d\t %e\t %e\t %e\t', ...
j,mean_MOF(j),sd_MOF(j),best_MOF(j));
for k = 1:size(best_params,2) % 2 specifies number of columns
fprintf(fileSTATS,'%e\t',best_params(j,k));
end
fprintf(fileSTATS,'%d\r\n',best_run(j));
end
Gen.: 1, mean: 1.777127e+00, SD: 7.709961e-01, Best: 6.468260e-01,
Parameters:
-5.762191e-02 -1.120718e+00
Run: 6
Gen.: 2, mean: 1.391021e+00, SD: 6.838437e-01, Best: 5.943482e-01,
Parameters:
1.074498e+00 -3.054331e+00
Run: 6
Gen.: 3, mean: 9.805492e-01, SD: 6.692086e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 4, mean: 9.805492e-01, SD: 6.692086e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 5, mean: 9.089068e-01, SD: 5.807616e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 6, mean: 9.089068e-01, SD: 5.807616e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 7, mean: 7.496810e-01, SD: 5.243635e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 8, mean: 7.496810e-01, SD: 5.243635e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 9, mean: 6.828632e-01, SD: 4.422585e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 10, mean: 5.668665e-01, SD: 4.279609e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 11, mean: 5.668665e-01, SD: 4.279609e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 12, mean: 5.668665e-01, SD: 4.279609e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 13, mean: 4.932501e-01, SD: 4.334705e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 14, mean: 4.347951e-01, SD: 2.915590e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 15, mean: 4.347951e-01, SD: 2.915590e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 16, mean: 4.347951e-01, SD: 2.915590e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 17, mean: 4.347951e-01, SD: 2.915590e-01, Best: 2.453411e-01,
Parameters:
-3.071395e+00 -1.000331e+01
Run: 2
Gen.: 18, mean: 4.140266e-01, SD: 3.049505e-01, Best: 2.018446e-01,
Parameters:
8.605031e-02 -2.182238e-02
Run: 4
Gen.: 19, mean: 3.720139e-01, SD: 3.401474e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 20, mean: 3.701877e-01, SD: 3.400666e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 21, mean: 3.701877e-01, SD: 3.400666e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 22, mean: 3.175751e-01, SD: 2.234774e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 23, mean: 3.175751e-01, SD: 2.234774e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 24, mean: 3.175751e-01, SD: 2.234774e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 25, mean: 3.175751e-01, SD: 2.234774e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 26, mean: 3.175751e-01, SD: 2.234774e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 27, mean: 2.435447e-01, SD: 1.174528e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 28, mean: 2.435447e-01, SD: 1.174528e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 29, mean: 2.435447e-01, SD: 1.174528e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 30, mean: 2.435447e-01, SD: 1.174528e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 31, mean: 2.372693e-01, SD: 1.183402e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 32, mean: 2.344517e-01, SD: 1.158099e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 33, mean: 2.344517e-01, SD: 1.158099e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 34, mean: 2.344517e-01, SD: 1.158099e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 35, mean: 2.237176e-01, SD: 1.222427e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 36, mean: 2.237176e-01, SD: 1.222427e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 37, mean: 2.237176e-01, SD: 1.222427e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 38, mean: 2.211849e-01, SD: 1.201115e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 39, mean: 2.211849e-01, SD: 1.201115e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 40, mean: 2.211849e-01, SD: 1.201115e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 41, mean: 2.211849e-01, SD: 1.201115e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 42, mean: 2.051711e-01, SD: 1.137674e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 43, mean: 2.051711e-01, SD: 1.137674e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 44, mean: 2.051711e-01, SD: 1.137674e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 45, mean: 2.051711e-01, SD: 1.137674e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 46, mean: 2.051711e-01, SD: 1.137674e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 47, mean: 1.963109e-01, SD: 1.105632e-01, Best: 4.179763e-02,
Parameters:
9.760521e-01 -1.021824e+00
Run: 1
Gen.: 48, mean: 1.884904e-01, SD: 1.170291e-01, Best: 1.857550e-02,
Parameters:
9.822058e-01 -9.849300e-01
Run: 1
Gen.: 49, mean: 1.872204e-01, SD: 1.168202e-01, Best: 1.857550e-02,
Parameters:
9.822058e-01 -9.849300e-01
Run: 1
Gen.: 50, mean: 1.872204e-01, SD: 1.168202e-01, Best: 1.857550e-02,
Parameters:
9.822058e-01 -9.849300e-01
Run: 1
fclose(fileSTATS);
Anibal Marrero le 14 Mar 2023
Modifié(e) : Anibal Marrero le 14 Mar 2023
I understand what you mean, but note that the process is taking place row by row:
1. Fill the jth row of MOF
2. Calculate mean of jth row of MOF
3. Calculate SD of jth row of MOF
4. Fill jth row of [best_MOF,best_index]
5. Fill the jth row of best_params (accordin to best_index(j))
6. Fill the jth row of best_run (accordin to best_index(j))
And so on, so it is not necessary to fully fill MOF before doing the rest.
Finally the little issue had simple solution.
I have accepted your answer since you have provided me the key to solve this problem.
Thank you.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Logical dans Help Center et File Exchange

R2020a

### Community Treasure Hunt

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

Start Hunting!

Translated by