I am working on control of robot puma560 by using Matlab Simulink which contains 5 Matlab function blocks. when I run a genetic algorithm to tune PD, it says too many output argument. does ga conflict with Matlab function blocks in Simulink or what?
%fitness function
function y=fit2(x)
global kp kv
kp=x(1);
kv=x(2);
disp([kp kv])
sim('new_sim2qaex')
y= mean(abs(error));
Too many output arguments.
Error in fit2 (line 8)
y= mean(abs(error));
Error in createAnonymousFcn>@(x)fcn(x,FcnArgs{:}) (line 11)
fcn_handle = @(x) fcn(x,FcnArgs{:});
Error in gamultiobjMakeState (line 27)
Score = FitnessFcn(state.Population(1,:));
Error in gamultiobjsolve (line 8)
state = gamultiobjMakeState(GenomeLength,FitnessFcn,ConstrFcn,output.problemtype,options);
Error in gamultiobj (line 274)
[x,fval,exitFlag,output,population,scores] = gamultiobjsolve(FitnessFcn,nvars, ...
Caused by:
Failure in initial fitness function evaluation. GAMULTIOBJ cannot continue.

댓글 수: 2

Walter Roberson
Walter Roberson 2019년 3월 25일
global variables act differently in Simulink. You should avoid using them.
asmaa abdelstar
asmaa abdelstar 2019년 3월 25일
How?

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2019년 3월 25일

0 개 추천

Assign a value to the variable error before calling sim
Otherwise, MATLAB will think you are referring to the function named error(), which does not have any outputs.

카테고리

태그

질문:

2019년 3월 25일

댓글:

2019년 3월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by