Too many output arguments. Requested 3 output(s), but only 1 output(s) available.

function cost_value=cost_func(k,plotfig)
ke=k(1,1);
kce=k(1,2);
ku=k(1,3);
X=k(1,4);
z_a=abs(k(1,5));
v_a=abs(k(1,6));
% negative big
NB=-X;
% negative medium
NM=-X/2;
% positive medium
PM=X/2;
% positive big
PB=X;
Z=0;
% Compute function value
opt = simset('solver','ode23tb','SrcWorkspace','Current');
[tout,xout,yout] = sim('ACO_TS.slx',[0 0.5],opt);
% compute the fitness value
z1=sqrt(mean(rmse)); % rms error
z2=(mean(iae)); % integral absolute error
z3=(mean(itae)); % integral time multiplied absolute error
z4=(mean(ise));
cost_value=z1+z2+z3+z4+mean(thd1);
Error using cost_func
Too many output arguments. Requested 3 output(s), but only 1 output(s) available.
Error in ACO (line 58)
cost(A)=cost_func(tour_selected_param,0); - Show complete stack trace

5 Comments

The block diagram looks like a Fuzzy PD plus fixed Integral controller. Are you trying find the gain values of ke, kce and ku using Ant Colony Optimizer (or any other optimization algorithm) that minimizes the overkill cost function of combined vectored square error (incorrectly labelled as rmse), ISE, IAE, and ITAE?
Is the system (plant) linear or nonlinear?
Yes I m trying to implement ant colony optimization technique for fuzzy logic that Is to be used in shunt active filter for UPQC.
Have you resolved the issue? Can you find the optimal gain values?
No the issue is not yet resolved. I am unable to find optimal gain values.
Can you count the number of output(s) available in your Simulink model? Perhaps you requested these three outputs (in individual vectored data form) from the Simulink model in the cost_func() function, but it's possible that you consolidated all the data into a single simulation output object named 'out', as pointed out by @Walter Roberson.
If you are unfamiliar with the object-oriented programming (the dot notation stuff), then better configure the Simulink model to log the requested data as tout, xout, yout, rmse (incorrect!), ise, iae, and itae.

Sign in to comment.

 Accepted Answer

You expect three outputs to be returned from sim() whereas only one output can be returned from sim() command

13 Comments

So just change your code to
Simout = sim('ACO_TS.slx',[0 0.5],opt);
% compute the fitness value
z1=sqrt(mean(out.rmse)); % rms error
z2=(mean(out.iae)); % integral absolute error
z3=(mean(out.itae)); % integral time multiplied absolute error
z4=(mean(out.ise));
Unable to resolve the name 'out.rmse'.
Error in cost_func (line 23)
z1=sqrt(mean(out.rmse)); % rms error
Error in ACO (line 58)
cost(A)=cost_func(tour_selected_param,0);
getting this error
@Sahithi Kandhukuri, it appears that you have decided to retain the Simulink.SimulationOutput object (Simout), which is perfectly fine.
Just out of curiosity, what is the exact purpose of calculating the mean values of cumulative ISE, cumulative IAE, and cumulative ITAE?
Additionally, what impact does minimizing the summation of these mean values (z1, z2, z3, z4) have on the fuzzy controller's gain?
In the screenshot you share ACO.m doesn’t seem to invoke cost_func() but the error shows it’s being invoked at line 58. If you want the problem to be debugged , please provide the necessary files to replicate your error.
As per out.rmse is concerned make sure the the To Workspace block parameter Save format is Array.
These are the related links and program I used
change this
Simout = sim('ACO_TS.slx',[0 0.5],opt);
to
out = sim('ACO_TS.slx',[0 0.5],opt);
Here's a simple example i created for you to understand:
a = 1;
b = 1;
V = func_cost(x, b)
function x = func_cost(a, b)
out = sim('Trial.slx');
x = a + b + out.tt;
end
x =
1
b =
1
Simout =
Simulink.SimulationOutput:
tout: [51x1 double]
tt: [51x1 double]
SimulationMetadata: [1x1 Simulink.SimulationMetadata]
ErrorMessage: [0x0 char]
ans =
2.0000
2.1987
2.3894
2.5646
2.7174
2.8415
2.9320
2.9854
2.9996
2.9738
2.9093
2.8085
2.6755
2.5155
2.3350
2.1411
1.9416
1.7445
1.5575
1.3881
1.2432
1.1284
1.0484
1.0063
1.0038
1.0411
1.1165
1.2272
1.3687
1.5354
1.7206
1.9169
2.1165
2.3115
2.4941
2.6570
2.7937
2.8987
2.9679
2.9985
2.9894
2.9407
2.8546
2.7344
2.5849
2.4121
2.2229
2.0248
1.8257
1.6335
1.4560
Ofcourse, you didn’t define that variable thd1. Attach your code as .m file.
yeah thank you for your support but the expected output should be as shown below.
Sorry my goal was to clear all the errors as stated in your original question. Regarding the correctness of your question , it"s better you post a new question.

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!