MATLAB Answers

data excel algorithm genetic

1 view (last 30 days)
joni nababan
joni nababan on 16 Feb 2020
Commented: Walter Roberson on 21 Feb 2020
how do i implement genetic algorithms with excel data for ranking

  2 Comments

Giuseppe Inghilterra
Giuseppe Inghilterra on 16 Feb 2020
Could you provide more details about your problem? (your trials, your code, etc..)
joni nababan
joni nababan on 20 Feb 2020
so i have problem to sort from highest to lowest value using matlab with genetic algorithm
can it be done?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 16 Feb 2020
Use readtable() or xlsread() to read the data. Once it is read into MATLAB, MATLAB does not care where it came from, so it becomes just the same as using any other array or vector when you construct the objective function to minimize.

  2 Comments

joni nababan
joni nababan on 20 Feb 2020
how about the genetic algorithm syntax code?
Walter Roberson
Walter Roberson on 21 Feb 2020
Use whatever is appropriate for your purpose and your solver.
Example:
t = readtable('YourFile.xlsx');
x = t.x;
y = t.y;
model = @(P) P(1)*log(x) + P(2)*x.^2 + sin((P(1)+P(2))*pi*x);
residue = @(P) sum((model(P) - y).^2);
nvars = 2; A = [1 -1]; b = 0; Aeq = []; beq = []; nonlcon = [];
[bestP, fval] = ga(residue, nvars, A, b, Aeq, beq, nonlcon);

Sign in to comment.

Sign in to answer this question.

Tags