Hello there, i’m trying to convert a Matlab code into Julia, but no success so far. Here it is. I’m loading some numeric data from a txt file.
workspace()
dados = readdlm("C:/Users/Muril/AppData/Local/atom/app-1.28.0/Arquivos Feitos/Dados.txt")
Nt = dados[2,12];
maxiter = dados[2,13];
tol = dados[2,14];
U0 = dados[2,15]*1e3;
delta = dados[2,16];
de = dados[2:Nt+1,1];
para = dados[2:Nt+1,2];
Lcomp = dados[2:Nt+1,3];
r = dados[2:Nt+1,4];
x = dados[2:Nt+1,5];
R = (r.*Lcomp);
X = (x.*Lcomp);
PLlin = (dados[2:Nt+1,7])*1e3;
QLlin = (dados[2:Nt+1,8])*1e3;
PLnlin = (dados[2:Nt+1,9])*1e3;
QLnlin = (dados[2:Nt+1,10])*1e3;
Qshunt = (dados[2:Nt+1,11])*1e3;
Perc = 105;
Qmod = dados[2,18]*1e3;
kj = dados[2,19];
fq = dados[2,20];
hmax = 25;
f = 60;
PLtotal = (PLlin + PLnlin);
QLtotal = (QLlin + QLnlin - Qshunt);
maiornivel = 1;
nivel = zeros(1,Nt);
nivel[find(de .== 0)] = maiornivel;
i = 0;
while nivel[sum(nivel .== 0)] >= 0
for i = 1:Nt
if nivel[i] == maiornivel
nivel[find(de .== i)] = maiornivel+1;
end
end
maiornivel = maiornivel+1;
if nivel != 0
break
end
end
Here, Nt = 17, and my “nivel” vector should be (got this from Matlab):
nivel = [1 2 3 4 5 6 7 8 9 4 3 4 5 5 6 6 7]
But when i run the above code in Juno, i get:
nivel = [1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
So, in my while loop, only one iteration is being made, but i don’t know why. Any help would be trully appreciated, thanks in advance!