Undefined function 'yout' for input arguments of type 'double'

8 views (last 30 days)
I'm building a model (test1) in Matlab for Hydraulic Valve as shown in the picture below.
When i try the optimization tool i get the following error: | | | Error running optimization. Undefined function 'yout' for input arguments of type 'double'. | | |
This is the code for the objective function i use:
function F = obj_find_valve_param_a_max(x,Q_r)
% Objective function to find the maximum valve area parameter value
% Copyright 2010 MathWorks, Inc.
assignin('base','a_max', x);
% If necessary, reset parameterizaton to second option (table)
model = 'test1';
load_system(model);
blkpth = find_system(bdroot,'ClassName','valve_dir_4_way');
set_param(char(blkpth),'mdl_type','1');
sim(model);
k = [1 1 1 0.9 0.8 0.7 0.6 0.5 0.4 0.3 0.2]; % Weight multipliers
% Computing objective function
F = 0;
for j = 1:11
F = F + k(j) * (yout(j) - Q_r(j))^2;
end
end
% EOF
The second file:
% Script to find directional valve parameter a_max
% Copyright 2010 MathWorks, Inc.
% This script file invokes optimization process to find the orifice
% area at maximum opening for 4-way directional valve when the valve is
% modeled using the first parameterization option (linear relationship
% between control signal and orifice area).
% init_opening - vaalve initial openings [mm]
% A_leak - leakage area [m^2]
% Q_r - vector of required flow rate at 11 valve displacements
% x0 - initial value for the only variable parameter: orifice maximum area
init_opening = -1; % mm
A_leak = 1e-9; % m^2
% Vector of required flow rates. Read out from plot on page 8 in
% Eaton/Vickers Porportional Directional Valves catalog for KBFDG5V-10 valve
% Actual flow rates are determined at fixed instances of time by exporting
% flow rate measured at the external loop of the valve to the MATLAB
% workspace
Q_r = [0 0 52 150 248 346 450 540 625 670 700];
% Set initial value of the orifice maximum area
x0 = 4.8; % [cm^2]
% Optimization
[x,fval,exitflag,output] = ...
fminsearch(@obj_find_valve_param_a_max,x0, ...
optimset('Tolx',1e-6,'Display','iter'),Q_r);
%bdclose all
If i remove from the first code yout(j) - Q_r(j) the iteration finishes successfully. Please does anyone knows how to deal with this error? Thanks.

Answers (1)

Andrew Reibold
Andrew Reibold on 9 Oct 2014
Edited: Andrew Reibold on 9 Oct 2014
yout is not a default Matlab function and hasn't been saved as a variable yet either. You, or a peer/coworker must have written it.
You need a copy of it, and you need to make sure it is saved in the working directory.

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!

Translated by