function [res, AFLAG] = do_cylinder_disk_fitd(A0start, tm, INPUTS,j) AFLAG = 0; INDEX = INPUTS{4}; dims = INPUTS{3}; Rp = dims{3}; Lp = dims{1}; npts = INDEX(2); y0 = [A0start,0]; cyl_length = Lp(j) - Rp; span = linspace(0, cyl_length, npts); options = odeset('OutputSel',4); [span, Atemp] = ode45(@cyl_derivs_disk_fitd, span, y0, options, tm, INPUTS); if (Atemp(end,2) > (span(end)+100*eps)) || (Atemp(end,2) < (span(end)-100*eps)) AFLAG = 1; else AFLAG = 0; end A0 = Atemp(:,1)'; res = [(span'); A0];