Skip to content

Fix bug in chisquare_inv.m related to vers variable parsing in MATLAB versions >= 10 #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions wave_matlab/chisquare_inv.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,12 @@
MAXX = 1; % actually starts at 10 (see while loop below)
X = 1;
TOLERANCE = 1E-4; % this should be accurate enough
vers = version;
vers = str2num(vers(1));

while ((X+TOLERANCE) >= MAXX) % should only need to loop thru once
MAXX = MAXX*10.;
% this calculates value for X, NORMALIZED by V
% Note: We need two different versions, depending upon the version of Matlab.
if (vers >= 6)
X = fminbnd('chisquare_solve',MINN,MAXX,optimset('TolX',TOLERANCE),P,V);
else
X = fmin('chisquare_solve',MINN,MAXX,[0,TOLERANCE],P,V);
end
MINN = MAXX;
MAXX = MAXX*10.;
% this calculates value for X, NORMALIZED by V
X = fminbnd('chisquare_solve',MINN,MAXX,optimset('TolX',TOLERANCE),P,V);
MINN = MAXX;
end

X = X*V; % put back in the goofy V factor
Expand Down