function [log] = log2var(logname)
fid = fopen(logname);
tline = fgetl(fid);
j = 0;
while ischar(tline)
    j = j + 1;
    if (~mod(j,1000))
        j
    end
    dvotocka = strfind(tline, ';');
    if(~mod(length(dvotocka),2))
        dvotocka(end+1) = length(tline)+1;
    end
    for i = 1:2:length(dvotocka)-1
        str = tline(dvotocka(i)+1:dvotocka(i+1)-1);
        eval(sprintf(['log.',str,'(',num2str(j),',1' ')=', (tline(dvotocka(i+1)+1:dvotocka(i+2)-1)),';']));
    end
    tline = fgetl(fid);
end

log.psi_hat = log.psi_hat .* 180 ./ pi;
abs_psi = 0;
for i = 2:j
    if ((log.psi(i) - log.psi(i-1) + abs_psi * 360) < -180)
        abs_psi = abs_psi + 1;
        log.psi(i) =  log.psi(i) + abs_psi * 360;
    elseif ((log.psi(i) - log.psi(i-1)) + abs_psi *360 > 180)
        abs_psi = abs_psi - 1;
        log.psi(i) =  log.psi(i) + abs_psi * 360;
    else
        log.psi(i) =  log.psi(i) + abs_psi * 360;
    end
end

fclose(fid);