researchws
May 19th, 2010, 05:39 AM
I have converted matlab code to java
My java code: (all the variables are already computed)
for(int i=1;i<=h2len;i++){
m = zd.from[zd.ppi[i]];
for(int j=1;j<=bpq.nbus;j++){
double t1 = zd.v[m]*zd.v[j];
double cosmj = Math.cos(zd.del[m]-zd.del[j]);
double sinmj = Math.sin(zd.del[m]-zd.del[j]);
double t2 = realybus[m][j]*cosmj + imagybus[m][j]*sinmj;
double t3 = t1 * t2;
double d1 = h2[i];
double d2 = t3;
double d3 = d1 + d2;
h2[i] = d3;
}
}
Matlab code:
for i = 1:npi
m = fbus(ppi(i));
for k = 1:nbus
h2(i) = h2(i) + V(m)*V(k)*(G(m,k)*cos(del(m)-del(k)) + B(m,k)*sin(del(m)-del(k)));
end
end
Problem:
upto 4 iterations i'm getting the same value for "h2" in java as matlab.
after that the value in java and matlab differs?
is there any conversion of double data type between java and matlab.
Please help me in this regards.
Thanks in advance
My java code: (all the variables are already computed)
for(int i=1;i<=h2len;i++){
m = zd.from[zd.ppi[i]];
for(int j=1;j<=bpq.nbus;j++){
double t1 = zd.v[m]*zd.v[j];
double cosmj = Math.cos(zd.del[m]-zd.del[j]);
double sinmj = Math.sin(zd.del[m]-zd.del[j]);
double t2 = realybus[m][j]*cosmj + imagybus[m][j]*sinmj;
double t3 = t1 * t2;
double d1 = h2[i];
double d2 = t3;
double d3 = d1 + d2;
h2[i] = d3;
}
}
Matlab code:
for i = 1:npi
m = fbus(ppi(i));
for k = 1:nbus
h2(i) = h2(i) + V(m)*V(k)*(G(m,k)*cos(del(m)-del(k)) + B(m,k)*sin(del(m)-del(k)));
end
end
Problem:
upto 4 iterations i'm getting the same value for "h2" in java as matlab.
after that the value in java and matlab differs?
is there any conversion of double data type between java and matlab.
Please help me in this regards.
Thanks in advance