就是电路模型转化为MATLAB代码的运算,代码已经有了。就是不知道怎么来的。看了好长时间不理解。
电路是这样一个简单的电路,但是代码不知道怎么回事?代码如下:
example5.m
c=590e-6; % input capacitance
r=0.127; % input capacitance series resistance
vmax=420.0; % maximum input voltage
vmin=400.0; % minimum input voltage
nv=5; % number of voltages to use
pmin=0.0; % minimum power
pmax=5000; % maximum power
np=10; % number of powers to use
[PCM2_L] = cpld(c,r,vmin,vmax,nv,pmin,pmax,np,s,NS,NI);
function = svec1(freqmin,freqmax,N)
s=(-1j*2*pi*logspace(log10(freqmin),log10(freqmax),N))';
其中所调用的函数如下:
函数一:
function = svec1(freqmin,freqmax,N)
Inputs:
% freqmin = minimum frequency, Hz
% freqmax = maximum frequency, Hz
% N = number of points
% Outputs:
% s = vector of s-plane values
s=(-1j*2*pi*logspace(log10(freqmin),log10(freqmax),N))';
函数二:
function [varargout] = cpld(c,r,vmin,vmax,nv,pmin,pmax,np,s,NS,NI)
% NS = number of sides used to represent the constraint boundary
% NI = number of interpolating points used to represent the constraint boundary
Outputs (2nd form of Call):
% CA,CB= Concatentated A,B,C, and D matrices with an input of the dc
% CC,CD current into load and output vector of the dc voltage at load terminals
if (nargout~=1)&&(nargout~=4)
error('Invalid number of output arguments');
end
% voltage variation
v0=linspace(vmin,vmax,nv);
% constant power load
p=linspace(pmin,pmax,np);
% dimension the A,B,C, D matrices appropriately
CA(1,np*nv)=0.0;
CB(1,np*nv)=0.0;
CC(1,np*nv)=0.0;
CD(1,np*nv)=0.0;
% compute the state space matrices
for k1=1:np,
for k2=1:nv,
index=k2+nv*(k1-1);
y=-p(k1)/(v0(k2)^2);
dinv=1.0/(1.0+r*y);
CA(index)=-y*dinv/c;
CB(index)=dinv/c;
CC(index)=dinv;
CD(index)=r*dinv;
end
end
if nargout==4
% pass out the concatentated state space description
varargout(1)={CA};
varargout(2)={CB};
varargout(3)={CC};
varargout(4)={CD};
else
% pass out the generalized source impedance
varargout(1)={stspchar1(CA,CB,CC,CD,1,s,NS,NI)};
end
主要的就是CA、CB、CC、CD不知什么意思?还有就是那个NS、NI也不是太明白。(程序默认为二端口网略)
|