⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ss2mat.m

📁 很多matlab的源代码
💻 M
字号:
function y = ss2mat(a,b,u)
% SS2MAT Convert state matrices to string state equations
%
%	Y = SS2MAT(A,B,U) converts state matrices to string state equations. 
%	A, B are state matrices for xdot=Ax+BU 
%	U is a string function of t for the input u(t)[default: U = [] ]
%	Y is the matrix of state equations in string form
%	USAGE: Y can be used for numerical solution of state equations. 
%	SEE ALSO ODERK1, ODESIMP, CTSIM.
%
%	SS2MAT (with no input arguments) invokes the following example:
%	% Generate the state equations from given A in aa, B in bb and U in uu
%	  >>aa = [0 -1;-2 -3];
%	  >>bb = [4;5];
%         >>uu = 't.*exp(-t)';
%         >>ys = ss2mat(aa,bb,uu)


% ADSP Toolbox: Version 2.0 
% For use with "Analog and Digital Signal Processing", 2nd Ed.
% Published by PWS Publishing Co.
%
% Ashok Ambardar, EE Dept. MTU, Houghton, MI 49931, USA
% http://www.ee.mtu/faculty/akambard.html
% e-mail: akambard@mtu.edu
% Copyright (c) 1998


if nargin==0,help ss2mat,disp('Strike a key to see results of the example')
pause,aa=[0 -1;-2 -3],bb=[4;5],uu='t.*exp(-t)',ys=ss2mat(aa,bb,uu),return,end

if nargin<3,u=[];end,
[m,n]=size(a); %m rows and n cols
y=[];mm=0;nn=0;
for k=1:m
x=[];
for j=1:n
if a(k,j)~=0,jj=int2str(j);x=[x '+(' num2str(a(k,j)) ')*y(' jj ')'];end
end
if ~isempty(u),if b(k)~=0;x=[x '+(' num2str(b(k)) ')*' u];end,end

lx=length(x);
if mm==0,y=x;nn=lx;else
if nn>lx,x=[x blanks(nn-lx)];end
if nn<lx,z=[y(1,:) blanks(lx-nn)];
for i=2:mm,z=[z;[y(i,:) blanks(lx-nn)]];end,
y=z;nn=lx;end
y=[y;x];
end
mm=mm+1;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -