www.gusucode.com > slcontrol 案例源码程序 matlab代码 > slcontrol/BatchComputeSteadyStateOPsForMultipleSpecificationsExample.m
%% Batch Compute Steady-State Operating Points for Multiple Specifications % This example shows how to find operating points for multiple operating % point specifications using the |findop| command. You can % batch linearize the model using the operating points and study the change % in model behavior. %% % Each time you call |findop|, the software compiles the Simulink model. To % find operating points for multiple specifications, you can give |findop| % an array of operating point specifications, instead of repeatedly calling % |findop| within a for loop. The software uses a single model compilation % to compute the multiple operating points, which is efficient, especially % for models that are expensive to recompile repeatedly. %% % Open the Simulink model. sys = 'scdspeed'; open_system(sys) %% % Create an array of default operating point specification objects. opspec = operspec(sys,3); %% % To find steady-state operating points at which the output of the rad/s to % rpm block is fixed, add a known output specification to each operating % point specification object. % blk = [sys '/rad//s to rpm']; for i = 1:3 opspec(i) = addoutputspec(opspec(i),blk,1); opspec(i).Outputs(1).Known = true; end %% % Specify different known output values for each operating point % specification. opspec(1).Outputs(1).y = 1500; opspec(2).Outputs(1).y = 2000; opspec(3).Outputs(1).y = 2500; %% % Alternatively, you can configure operating point specifications using % the Linear Analysis Tool and export the specifications to the MATLAB % workspace. For more information, see <docid:slcontrol_ug.btmmc_w>. %% % Find the operating points that meet each of the three output % specifications. |findop| computes all the operating points using a single % model compilation. ops = findop(sys,opspec); %% % |ops| is a vector of operating points for the |scdspeed| model that % correspond to the specifications in |opspec|. The output value for each % operating point matches the known value specified in the corresponding % operating point specification.