clear all %#ok<*CLALL>
close all
clc

global x
global d

x = -10:5:10;
d = x+1+randn(size(x));

nVariables = 2;
coefs = ga(@myFitnessLinEqn,nVariables);

a=coefs(1);
b=coefs(2);
y=a*x+b;

plot(x,d, 'b')
hold on
plot(x,y, 'r');