📄 ssts__tether_mmet_ii_discrete_number_sfunction_ii.m
字号:
function [sys,x0,str,ts] = SSTS__tether_MMET_II_discrete_number_sfunction_II(t,x,u,flag)
% /*M-FILE Function SSTS__tether_MMET_II_discrete_number_sfunction_II MMM SSTSLAB */
% /*==================================================================================================
% Simple Space Tether Simulation Laboratory Toolbox for Matlab 7.x
%
% Copyright 2007 The SxLAB Family - Yi Chen - leo.chen.yi@gmail.com
% ====================================================================================================
%File description:
% this sfunction is to calculate the sum from 1~N ( MMET-II discrete point masses )
%
% 2*idx - 1
% ___________________________________ _
%
% ( R^2 - (2*idx-1)*R*L*cos(psi)/N +
% ((2*idx-1)*L/2/N))^2 )^(3/2);
%
% 2*idx - 1
% ___________________________________
%
% ( R^2 + (2*idx-1)*R*L*cos(psi)/N +
% ((2*idx-1)*L/2/N))^2 )^(3/2);
%
%Input:
%
% t -- time [Not modify]
% x -- state of s funciton [Not modify]
% u -- inputs vector , where [by user]
% u(1) -- N, number of point masses ( 20 in default)
% u(2) -- R, radius of orbit
% u(3) -- L,length of tether
% u(4) -- psi, rotate angle in plane of tether
% flag -- flat status [No modify]
%
%Output:
% sys -- outputs vector [by user]
% x0 -- sfunction std output [Not modify]
% str -- sfunction std output [Not modify]
% ts -- sfunction std output [Not modify]
%
% Appendix comments:
% follow the example of timestwo.m, provide by matlab
%
% Usage:
%
%
%===================================================================================================
% See Also: SSTS__tether_MMET_II_discrete_number_sfunction_I
% SSTS__tether_MMET_II_discrete_number_sfunction_II
% SSTS__tether_MMET_II_discrete_number_sfunction_III
%
%===================================================================================================
%
%===================================================================================================
%Revision -
%Date Name Description of Change email Location
%22-Dec-2006 Chen Yi Initial chenyi2005@gmail.com Glasgow
%HISTORY$
%==================================================================================================*/
% SSTS__tether_MMET_II_discrete_number_sfunction_II Begin
% The following outlines the general structure of an S-function.
%
switch flag,
case 0,
[sys,x0,str,ts] = mdlInitializeSizes;
case 3
sys=mdlOutputs(t,x,u);
%%%%%%%%%%%%%%%%%%%
% Unhandled flags %
%%%%%%%%%%%%%%%%%%%
% There are no termination tasks (flag=9) to be handled.
% Also, there are no continuous or discrete states,
% so flags 1,2, and 4 are not used, so return an emptyu
% matrix
case { 1, 2, 4, 9 }
sys=[];
otherwise
error(['Unhandled flag = ',num2str(flag)]);
end
% SSTS__tether_MMET_II_discrete_number_sfunction_II End
%=============================================================================
% mdlInitializeSizes
% Return the sizes, initial conditions, and sample times for the S-function.
%=============================================================================
%
function [sys,x0,str,ts]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = 0; % x
sizes.NumOutputs = 1; % sys
sizes.NumInputs = 4; % u
sizes.DirFeedthrough = 1; % if 0, not direct feedthrough, we need have flag = 2
% if 1, has direct feedthrough, we dont need
% flag = 2 ,
sizes.NumSampleTimes = 1; % at least one sample time is needed
sys = simsizes(sizes);
str = []; % str is always an empty matrix
x0 = []; % initialize the initial conditions
ts = [-1 0]; % inherited sample time ,initialize the array of sample times
% end mdlInitializeSizes
%=============================================================================
% mdlOutputs
% Return the output vector for the S-function
%=============================================================================
%
function sys = mdlOutputs(t,x,u);
[sys] =sum_point_mass(u);
% u(1) -- N, number of point masses ( 20 in default)
% u(2) -- R, radius of orbit
% u(3) -- L,length of tether
% u(4) -- psi, rotate angle in plane of tether
% end mdlOutputs
function [ sum_mass] = sum_point_mass( u )
% u(1) -- N, number of point masses ( 20 in default)
% u(2) -- R, radius of orbit
% u(3) -- L,length of tether
% u(4) -- psi, rotate angle in plane of tether
sum_mass = 0;
for idx = 1 : 1 : u(1)
sum_mass = sum_mass + ...
( ( ( u(2)^2 - (2*idx-1)*u(2)*u(3)*cos(u(4))/u(1) + ((2*idx-1)*u(3)/2/u(1))^2 )^(-3/2) - ...
( u(2)^2 + (2*idx-1)*u(2)*u(3)*cos(u(4))/u(1) + ((2*idx-1)*u(3)/2/u(1))^2 )^(-3/2) )*...
( 2*idx - 1 ) ) ;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -