Undefined function 'yout' for input arguments of type 'double'
1 次查看(过去 30 天)
显示 更早的评论
I'm building a model (test1) in Matlab for Hydraulic Valve as shown in the picture below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/145656/image.png)
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.
0 个评论
回答(1 个)
Andrew Reibold
2014-10-9
编辑:Andrew Reibold
2014-10-9
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modeling Fundamentals and Processes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!