I am getting error Not enough input arguments..

1 回表示 (過去 30 日間)
Don Alexander
Don Alexander 2015 年 5 月 29 日
回答済み: Walter Roberson 2015 年 5 月 29 日
function q = simple_sa(x)
z1 = xlsread('staad.xlsx','A:A');
z2= xlsread('staad.xlsx','B:B');
z1_new=z1(2)
z2_new=z2(2)
q = z1_new* (x(1)^2 + x(2)) ^2 + (z2_new + x(1))^2
FitnessFunction = @simple_sa;
numberOfVariables = 2;
[x,fval] = ga(FitnessFunction,numberOfVariables)
I am getting error Not enough input arguments..
Above code was a trial...
My problem is to use ga code in such a wat that the matlab reads values from an excel sheet , the it passes it(like values of z above) to the objective and constraint func, the running ga code for each value taken and returns the output untill all the cells are read.... help......most wanted........
  2 件のコメント
Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2015 年 5 月 29 日
Dear Don,
Please have a look at this link first to see how you have to format your question. It's so annoying to follow it that I didn't even bother to do so!
Muhammad Usman Saleem
Muhammad Usman Saleem 2015 年 5 月 29 日
Firstly format your codes then i shall gives you answer

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

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 5 月 29 日
function do_my_fittings
z1 = xlsread('staad.xlsx','A:A');
z2 = xlsread('staad.xlsx','B:B');
L = min(length(z1), length(z2));
xvals = zeros(L, 2);
for K = 1 : L
xvals(K, :) = simple_fitness(z1(K), z2(K));
end
end
function x = simple_fitness(z1i, z2i)
q = @(x) z1i .* (x(1)^2 - x(2)).^2 + (z2i - x(1)).^2;
FitnessFunction = q;
numberOfVariables = 2;
[x,fval] = ga(FitnessFunction,numberOfVariables)
end

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by