use of dynamic field within fitness function using GA from optimtool

My GA problem exists in estimating filter parameters, which I can resolve just fine using GA for one patient and one trial.
What I want to do : Create a batch to run this several times (x amount of trials) for each specific patient (note: I am currently not looking for an additive/nested GA which would give me a global solution. I just want to execute the GA on individual data without having to manually enter the command for each file and adapting the fitness function. [schematic representation] for i=1:subjects for j=1:trials [x,fval]=GA_from_optimtools_related_to_fitnesFc(...) ....
My question: In my current GA fitness function I am loading the data file
function [TRE] = fit_test(filter_param)
% entry data
fs=1000;
cd G:\data\folder\patient\condition_1\Upsampled\
load('data.mat')
...
I am looking for a way to place this outside of the fitness function so that I can loop it (execute the GA for all the trials of each patient; remember I am not looking for one global solution, I want to obtain the optimized parameters for each separate trial). I have tried creating a variable (containing the folder and file name)and making it global, to then load it from within the fitness function -> but failed to do this on the compiled GA.
Can anyone please give me some pointers or point me towards some documentation clarifying this issue?

 Accepted Answer

I think that this is a base MATLAB programming question, it is not specific to GA. If I understand you correctly, you want to end up with fitted parameters for each patient, and each patient might have a set of parameters, one for each trial.
So the question becomes what is a format to hold all this data. Perhaps a cell array, where A{i,j} is the set of parameters for patient i at trial j. Perhaps you can think of a better format for holding the data. Whatever you come up with, load your data, and loop over the data, and stick the results in the cell array or whatever you use to hold the data.
I hope this helps. If I didn't answer your question, please try asking again.
Alan Weiss
MATLAB mathematical toolbox documentation

1 Comment

Thank you Alan, I was hoping for a "cleaner" version that did not require loading that amount of data, but at least this works!

Sign in to comment.

More Answers (0)

Products

Asked:

on 28 Jan 2014

Commented:

on 28 Jan 2014

Community Treasure Hunt

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

Start Hunting!