highSpikes = 1; % the transition of interest sysName = 'equalspiralband300'; % the name of the model paramType = 'value'; % the type of field in the blocks maxLoops = 30; % number of times to halve the range of conductances digits = 6; % number of digits (sort of) numFlops= 25; % number of times to go from band start to band stop rangeMult = 10; % how much do we expand the range when it is too small maxRangeMults = 5; % how many times do we try to expand it direction = -1; % do the number of spikes increase (1) or decrease (-1) with the block values? slowBlockName = '/I_Aslow/gbarI_A'; % name of block controling band stop slowHighRange = 1; % guess at highest max conductance slowLowRange = 0; % guess at lowest max conductance longCut = 1350; % time in ms of desired band stop fastBlockName = '/I_A/gbarI_A'; % name of block controling band start fastHighRange = 1; % guess at highest max conductance fastLowRange = 0; % guess at lowest max conductance shortCut = 1200; % time in ms of desired band start1 %^^^^^^^^^^^^^^^^^^^^^^^^^^^ I'll try to keep user params above here ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ % Run all of the simulations 1000ms longer than the end of the band simTime = longCut + 1000; % start on the short (0) side not the long (1) side side = 0; % Set up for breakpoint on each flop for i = 1 : numFlops, if (side == 0), highRange = fastHighRange; lowRange = fastLowRange; blockName = strcat(sysName, fastBlockName); set_param(strcat(sysName, '/I_inj/Syn/end'), 'time', num2str(shortCut)); else, highRange = slowHighRange; lowRange = slowLowRange; blockName = strcat(sysName, slowBlockName); set_param(strcat(sysName, '/I_inj/Syn/end'), 'time', num2str(longCut)); end; % we get the old conductance level fore some reason... strange blockValue = str2double(get_param(blockName, paramType)); % here is a test of the range we are given % if the range is bad we change it right away to avoid % the waisted effort of reducing it every time loopCount = 1; goodRange = [0 0]; while ((goodRange ~= [1 1]) & (loopCount < maxRangeMults)), range = highRange - lowRange; set_param(blockName, paramType, num2str(highRange, digits)); sim(sysName, simTime); if (size(spikes,1) >= highSpikes) & (direction == -1), highRange = highRange * rangeMult; elseif (size(spikes,1) < highSpikes) & (direction == 1), highRange = highRange * rangeMult; else goodRange(2) = 1; end; set_param(blockName, paramType, num2str(lowRange, digits)); sim(sysName, simTime); if (size(spikes,1) < highSpikes) & (direction == -1), lowRange = lowRange / rangeMult; elseif (size(spikes,1) >= highSpikes) & (direction == 1), lowRange = lowRange / rangeMult; else, goodRange(1) = 1; end; loopcount = loopCount + 1; end; % here is the beginning of breakpoint loopCount = 1; range = highRange - lowRange; while ((loopCount <= maxLoops) & (ceil(log10(range)) > -digits)), blockValue = lowRange + range / 2; set_param(blockName, paramType, num2str(blockValue, digits)); sim(sysName, simTime); if (size(spikes,1) < highSpikes) & (direction == -1), highRange = blockValue; end; if (size(spikes,1) >= highSpikes) & (direction == -1), lowRange = blockValue; end; if (size(spikes,1) >= highSpikes) & (direction == 1), highRange = blockValue; end; if (size(spikes,1) < highSpikes) & (direction == 1), lowRange = blockValue; end; range = highRange - lowRange; loopCount = loopCount + 1; end; %[loopCount i] disp([side lowRange highRange]) %precision = 10^(ceil(log10(range))) if (side == 0), fastHighRange = highRange; fastLowRange = lowRange; %fastHighRange = highRange + range * rangeMult; %fastLowRange = lowRange - range * rangeMult; %fastHighRange = highRange * rangeMult; %fastLowRange = lowRange / rangeMult; side = 1; else, slowHighRange = highRange; slowLowRange = lowRange; %slowHighRange = highRange + range * rangeMult; %slowLowRange = lowRange - range * rangeMult; %slowHighRange = highRange * rangeMult; %slowLowRange = lowRange / rangeMult; side = 0; end; end;