#585 Freemat 4.1 Windows crashes

open
nobody
5
2013-04-27
2013-04-27
Anonymous
No

I am trying to run a simple correlation program, and this crashes the Windows GUI. I don't have access to MATLAB to see if this runs correctly.

Thanks,
AB

total = 10000;
dum = floor (rand (total, 1) + 0.5);
a = 0;
lagstart = 90;
lagend = 9999;
for k = lagstart:lagend
dee = dum(k+1:total);
newa = correlation (dum(1:total-k), dee);
a = [a newa];
end

The function is defined as

function ac = correlation (dum, dee)

sd_of_dum = sqrt (var (dum))
sd_of_dee = sqrt (var (dee))
product = dum .* dee

cov_of_dum_vs_dee = mean (product) - mean (dum) * mean (dee)

if sd_of_dum ~= 0 & sd_of_dee ~= 0
ac = cov_of_dum_vs_dee/(sd_of_dum * sd_of_dee)
else
ac = 0
disp ('One of the SDs is 0')
end

Discussion


  • Anonymous
    2013-04-27

    The trouble seems to be in the semicolon in the line with function call

    newa = correlation (dum(1:total-k), dee);

    If I removed the semicolon, this works correctly.