www.gusucode.com > simulinktest 案例源码程序 matlab代码 > simulinktest/AssessingWingDampingCustomCriteriaExample.m

    %% Assess the Damping Ratio of a Flutter Suppression System
% Use a custom criteria script to verify the damping ratio in a test case
% that simulates the flutter suppression system of a wing.
%
%% The Simulation and Model
%
% The model uses Simscape(TM) to simulate a Benchmark Active Controls
% Technology (BACT) / Pitch and Plunge Apparatus (PAPA) setup.  It uses 
% Aerospace Blockset(TM) to simulate arodynamic forces on the wing.
%
% The test iterates over 16 combinations of |Mach| and |Altitude|. The test
% case uses custom criteria with Curve Fitting Toolbox(TM)
% to find the peaks of the wing pitch, and determine the damping ratio.
% If the damping ratio is not greater than zero, the assessment fails.
%%
% Running this test case requires
%
% * Simulink(R) Test(TM)
% * Simscape Multibody(TM)
% * Aerospace Blockset(TM)
% * Curve Fitting Toolbox(TM)

%% 
%
% Open the model and the test file.
open_system(fullfile(matlabroot,'examples','simulinktest',...
    'sltestFlutterSuppressionSystemExample.slx'))

%%
%
open(fullfile(matlabroot,'examples','simulinktest',...
    'sltestFlutterCriteriaTest.mldatx'))

%% Custom Criteria Script
%
% The test case custom criteria uses this script to verify that the damping
% ratio is greater than zero.
%%
%   % Get time and data for pitch
%   Time = test.SimOut.get('sigsOut').get('pitch').Values.Time(1:15000);
%   Data = test.SimOut.get('sigsOut').get('pitch').Values.Data(1:15000);
% 
%   % Find peaks
%   [~, peakIds] = findpeaks(Data,'minpeakheight', 0.002, 'minpeakdistance', 50);
%   peakTime= Time(peakIds);
%   peakPos = Data(peakIds);
%   rn = peakPos(1)./peakPos(2:end);
%   L = 1:length(rn);
% 
%   % Do curve fitting
%   fittedModel = exponentialFitAndPlot(L, rn);
%   delta = fittedModel.d;
% 
%   % Find damping ratio
%   dRatio = delta/sqrt((2*pi)^2+delta^2);
%   
%   % Make sure damping ratio is greater than 0
%   test.verifyGreaterThan(dRatio,0,'Damping ratio must be greater than 0');
%
%% Test Results
%
% Running the test case returns two conditions in which the damping ratio
% is greater than zero.
results = sltest.testmanager.run

%%
% <<../flutter_test_result.png>>

%%
% The wing pitch plots from iteration 12 and 13 show the
% difference between a positive damping ratio (iteration 12) and a negative
% damping ratio (iteration 13).
% 
% <<../flutter_sdi.png>>

%%
sltest.testmanager.close
%%
close_system('sltestFlutterSuppressionSystemExample.slx',0)