I have a cell array which each cell is an n-by-n matrix. I want to delete the cells for which inv(cell{i}'*cell{i}) gives warning that matrix is close to singular.
Thank you
I have a cell array which each cell is an n-by-n matrix. I want
Share
In general, removing elements is the easy part. If
Cis your array, removing cells specified by the indices in vectoridxcan be done by:Regarding your specific problem, to check if a matrix is “almost” singular or not can be done with
rcond(if the result is close to zero, it’s probably singular). To apply it to all cells you can usecellfunin the following way:Adjust the threshold value to your liking. The resulting
idxis a logical array with1s at the location of singular matrices. Useidxto remove these elements fromCas shown above.