Matlab crashes/closes unexpectedly while saving the matrix

Hi,
I am running my codes in the Matlab that installed in the server. My code deals with processing 5000 files in a for loop, at the end I suppose to save one big matrix.
I have observed crash /unexpected close of matlab duirng follwing instants.
  1. Everything was normal till last iteration of for loop i.e. 5000, it closes amid saving my big matrix. Actually, the size of the matrix is 500 mb, previuoly I was succesful in saving matrix of ~10 gb with the same code.
  2. Sometimes I am succesful in saving the matrix, however, matlab closes while I am trying to read the saved matrix..
Could someone advice me in this ??

8 Comments

Yes.. Thanks..
Just did.. Lets see what they come up with..
My pleasure!
Please post back.
I doubt if my code is the problem, however I’m concerned that if so it may need tweaking to avoid the crash.
Actually I am running your code in different server.. There it is running smoothly.. So, No worries ...
Cheers !!!
BTW, I am intend to find the symmtery in the image, for e.g. finding symtericity about y axis in the case of attached figure, Have you dealth anything similar to this ??
Actually I am running your code in different server.. There it is running smoothly.. So, No worries ...
<sigh of relief>
"I am intend to find the symmtery in the image" - prefer to ask a new question for a new problem.
The answer will be: There is no symmetry in this image.

Sign in to comment.

 Accepted Answer

BTW, I am intend to find the symmtery in the image, for e.g. finding symtericity about y axis in the case of attached figure, Have you dealth anything similar to this ??
I have not. However it doesn’t appear to me to be symmetrical. One option may be to use the centroid function (introduceed in R2017b) to get the (x,y) coordinates. You can then use the ‘x’ value to calculate the symmetry. I am not certain how best to define ‘symmetry’ or test for it.
On an interweb search, I was only able to find one File Exchange contribution that might be useful: Novel Method for Determining Symmetry of Skin Lesions using the Jaccard Index, so it woould likely be worthwhile to search the File Eschange to see if there are others that could apply to what you want to do.
Taking a stab at this just for fun, using the ‘x{1}’ and ‘y{1}’ results from my previous Answer
ps1 = polyshape(x{1},y{1}); % Create Polyshape Object
[xc,yc] = centroid(ps1) % Centroid
flipcurv = x{1}<=xc; % Logical Indices To Left Of Centriod ‘x’ Value
xfc = xc - x{1}(flipcurv); % Flipped ‘x’-Coordinates
yfc = y{1}(flipcurv); % Corresponding ‘y’-Coordiantes
xrc = x{1}(~flipcurv)-xc; % Right-Hand-Side Of Contour ‘x’-Coordinates (Not Flipped)
yrc = y{1}(~flipcurv); % Right-Hand-Side Of Contour ‘y’-Coordinates (Not Flipped)
ang1 = atan2(yfc-yc,xfc); % Angles
r1 = hypot(yfc-yc, xfc); % Radii
[Uar1,ar1ix] = unique([ang1(:),r1(:)], 'rows'); % Unique [Angles Radii]
afi = linspace(min(Uar1(:,1)), max(Uar1(:,1)), 1000); % Interpolation Vector
rfi = interp1(Uar1(:,1), Uar1(:,2), afi); % Interpolated Value
ang2 = atan2(yrc-yc,xrc); % Angles
r2 = hypot(yrc-yc, xrc); % Radii
[Uar2,ar2ix] = unique([ang2(:),r2(:)], 'rows'); % Unique [Angles Radii]
ari = linspace(min(Uar2(:,1)), max(Uar2(:,1)), 1000); % Interpolation Vector
rri = interp1(Uar2(:,1), Uar2(:,2), ari); % Interpolated Value
[r,p] = corrcoef(rfi(:),rri(:)); % Correlation (One Of Many Possible Measures Of Similarity)
[xfi,yfi] = pol2cart(afi,rfi); % Convert Back To Cartesian
[xri,yri] = pol2cart(ari,rri); % Convert Back To Cartesian
figure
plot(xfc, yfc)
hold on
plot(xrc, yrc)
hold off
grid
axis('equal')
figure
plot(xfi,yfi)
hold on
plot(xri,yri)
hold off
grid
axis('equal')
title('Interpolated & Re-Plotted Overlapped Curves')
legend('Flipped Left-Half', 'Original Right-Half', 'Location','best')
This code produces equal-length vectors (plotted) that can now be compared with each other in any number of ways. I defer to you to explore those options!
.

7 Comments

Many thanks for detailed response.. I will look into the centroid option, which I believe serve my requirements...
Thanks again...
My pleasure!
I use centroid in my code here to split the contour and overlap the left and right halves. With that, assessing left-right symmetry is possible.
Hi,
Could you please provide some insights on how to intepret r,p values in r,p] = corrcoef(rfi(:),rri(:));
I will do my best, although others with more sophisticated statistics knowledge can likely expand on it.
The ‘r’ value is the correlation coefficient. (The documentation goes into detail as to how it’s calculated.) It goes from -1 (highly correlated however in the opposite direction) to +1 (highly correlated in the same direction). So for example —
A = 1:5;
B = 5:-1:1;
[r,p] = corrcoef(A,A)
r = 2×2
1.0000 1.0000 1.0000 1.0000
p = 2×2
1.0000 0.0000 0.0000 1.0000
[r,p] = corrcoef(A,B)
r = 2×2
1.0000 -1.0000 -1.0000 1.0000
p = 2×2
1.0000 0.0000 0.0000 1.0000
A correlation coefficient near 0 indicates that the two vectors are essentially random and that there is no relationshhip between them.
[r,p] = corrcoef(rand(1,5), rand(1,5))
r = 2×2
1.0000 -0.0386 -0.0386 1.0000
p = 2×2
1.0000 0.9509 0.9509 1.0000
The ‘p’ values are the probability that the correlation is due to simple random process. A p-value of 0.05 or less indicates that this is unlikely (‘statistically significant’, a value arrived at more than a century ago by Sir Ronald Fisher if I remember correctly), and the correlation is real. There are more detailed discussions in the documentation for corrcoef and corr. Neither discusses the underlying distribution for the p-values, so I assume the statistics are normally-distributed.
Wikipedia of course has extensive discussions of the Correlation coefficient and Correlation and dependence.
.
Thanks a lot. Now, I can understand much better..
I have just posted new thread on seeking solutions into the inetnsity correction in the images..
Please do have a look.. Sorry for too many questions..

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!