Hi,
As per my understanding, you're encountering errors when fitting heat maps of biological cells using MATLAB's lsqcurvefit, due to incompatible fitting parameters for a few outlier cells.You're looking for a way to skip the problematic cells and keep the program running uninterrupted for the rest.
A try-catch block can be implemented around the fitting code. This way, when MATLAB encounters an error for certain cells, it can catch the error and skip those problematic cells, proceeding to the next ones without stopping the entire process.
Please refer to the code snippet below:
for i = 1:numberOfCells % Assuming numberOfCells is the total number of cells you are iterating over
try
% Your current fitting process for each cell
[iCell{iFrame}]=FitObj.FittingFunction(iCell{iFrame},signal,MaximumPeakNumber);
catch ME
% Here, you catch the error and decide what to do. For simplicity, we'll just display a message.
fprintf('Skipping cell %d due to fitting error: %s\n', i, ME.message);
continue; % This will skip the rest of the loop and move to the next cell
end
end
Please refer to the documentation of 'try, catch' for more information on executing statements and resulting errors:
I hope this helps!