필터 지우기
필터 지우기

matrix loop doesnt work

조회 수: 2 (최근 30일)
samuel herrera
samuel herrera 2021년 11월 13일
댓글: Star Strider 2021년 11월 13일
how can i make a loop with the matrix a, because its not working
G=10*10-9;%
l=1*10^-3;
c=10*10^-9;
u=4*pi*10^-7;
e=(l*c)/u;
g=(u*G)/l;
vs=1;
f=60;
zs=50;
long=10:10:100;
w=2*pi*f;
z0=((j*w*l)/(g+j*w*c))^(1/2);
prop=(j*w*l*(g+j*w*c))^(1/2);
zl=30+10j;
%problem%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:length(long)
a=[(z0+zs) (z0-zs);(z0-zl)*exp(-prop*long(i)) (z0+zl)*exp(prop*long(i))];
b=[z0*vs;0];
ain=inv(a);
v=ain*b;
vp(i) = v(1);
vn(i) = v(2);
vt(i)=vp(i)+vn(i);
end
plot(long,vt)
Warning: Imaginary parts of complex X and/or Y arguments ignored.
  댓글 수: 3
Jan
Jan 2021년 11월 13일
편집: Jan 2021년 11월 13일
"It is not working" is not a useful description of the problem. Yu know already, what's going wrong. Then it helps to solve your problem, if you share this knowledge.
Your code runs fine. So maybe the result differ from your expectations?
Star Strider
Star Strider 2021년 11월 13일
See if the expm function helps to produce the desired result.
It looks as though the code is attempting to model a state-space system of some sort, although it is not clear to me what it does.
.
.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Quadratic Programming and Cone Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by