implement for loop program

Status
Not open for further replies.

shegmite

Member level 1
Joined
Apr 8, 2012
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,496
Please can anyone help me with this for loop program. I have this problem with making the outputs from the for loop do serial multiplication.
f = 25 ;
for m = 0:10:80;
Zcb = 104.5;
l = 3.75e-3 ;
Zo = (1 + (0.055*(1-1i))/sqrt(f));
n = 800 ;
x = 1;
P = 800;
Z1 = 1+((m)*sin(2*pi*n*x/P));
ZB = abs(Zcb*Zo*Z1);
u = ((494)+(36/f))*1.0e-9;
Vpk = 100/u ;
Attk = (1.80*sqrt(f)+ 0.005*(f)+ 0.25/sqrt(f));
Qk = ((Attk)*(0.01))/(8.68588963807);
Bk = (2*pi*f*1.0e6)/(Vpk);
Yk =(Qk + 1i*Bk);
H = (1.0000 + 0.0000i);
N = (0.0000 + 0.0029i);
Ds = (2*ZB.*Zo*H) + ((ZB.^2+Zo^2)*N);
SB11 = ((ZB.^2-Zo^2)*N)/Ds;
SB12 = (2*ZB.*Zo)/Ds;
SB21 = (2*ZB.*Zo)/Ds;
SB22 = ((ZB.^2-Zo^2)*N)/Ds;
% Program to convert S matrix to T matrix
TB11 = ((SB12*SB21)-(SB11*SB22))/SB21;
TB12 = (SB11/SB21);
TB21 = -(SB22/SB21);
TB22 = (1/SB21);
TB = [TB11 TB12;TB21 TB22];
end
% program to get the sequential product of TB from the for loop above
T = TB1*TB2*TB3*TB4*TB5*TB6*TB7*TB8*TB9*TB10;
 

I use Scilab, but probably Matlab is very similar.
If you have the 2x2 matrices TB1, TB2, TB3...TB10, you can define an hypermatrix TH (in this case a vector of matrices) as:

TH(1:2,1:2,1)=TB1;
TH(1:2,1:2,2)=TB2;
.
.
TH(1:2,1:2,10)=TB10;

then the product can be calculated as:

T=TB1;
for i=2:10,
T=T*TH,:,i);
end

The 2x2 matrix product of TB1 to TB10 is T.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…