matlab says busy but isn't doing anything while running a script
10 views (last 30 days)
Show older comments
Here's my code:
%Reading in data into two matrices from the knnsearch function
%to be used in determining the smoothing length to give a particle
function filename = neighborsearch(tracer_x,tracer_y)
IDX(1:4999, 1:4000, 1:10) = 0;
D(1:4999, 1:4000, 1:10) = 0;
%The IDX and Distance matrices are initialized
%
for i=1:4999 %looping through all frames
[IDX(i,:,:), D(i,:,:)] = knnsearch([(tracer_x(i,:))',(tracer_y(i,:))'], [(tracer_x(i,:))', (tracer_y(i,:))'], 'k', 10);
end
end
I'm trying to output two matrices with particle id's and distances to nearest neighbors (1-10 in this, but 1-15 would be preferred). I changed it to n_max = 10 because when I tried to execute the script with 15 neighbors I got a "OUT OF MEMORY" error; So when I try to run it with 10, matlab says busy at the bottom but nothing happens, nothing is output or saved into the workspace, nada. Have I simply written the code wrong or is this pushing it on my available memory? I'll include the memory output just in case. I'm working on Windows 64-bit, Matlab 64-bit R2015a.
Thanks!
>> memory
Maximum possible array: 4433 MB (4.648e+09 bytes) *
Memory available for all arrays: 4433 MB (4.648e+09 bytes) *
Memory used by MATLAB: 1755 MB (1.840e+09 bytes)
Physical Memory (RAM): 4000 MB (4.194e+09 bytes)
* Limited by System Memory (physical + swap file) available.
8 Comments
Image Analyst
on 26 Jun 2015
How long does it go before you decide it's not doing anything with this large chunk of data? If you're doing knnsearch, it probably does take a long time. Chances are you can do it on a subset of the data and get results just as good.
Star Strider
on 26 Jun 2015
One thing I do for long simulations is to put in an fprintf call as the last statement before the end of the loop:
fprintf('\tLoop: %4d at %4d-%02d-%02d %02d:%02d:%06.3f\n', i, datevec(now))
It will tell you where it is in the loop, about how long each loop is taking, and probably won’t add significant overhead. (I usually add an etime call, but then I like details.)
Answers (1)
Kelly Kearney
on 26 Jun 2015
You need to assign the proper output variables. My guess is you're calling the function by typing
neighborsearch(tracer_x,tracer_y)
at the command line. Because you don't request any output variables, the function doesn't throw an error, and runs perfectly fine. On the other hand, if you had typed
filename = neighborsearch(tracer_x,tracer_y)
as the function syntax implied you may have wanted, it would throw the error everyone is talking about above.
But to get back to your original problem, I think your function is working fine, but after it completes its calculations, it throws them away because you didn't tell it to do anything with the new matrices. You need to make sure to return the output you actually want, which I believe are the IDX and D variables.
Change the function itself to:
function [IDX, D] = neighborsearch(tracer_x,tracer_y)
IDX(1:4999, 1:4000, 1:10) = 0;
D(1:4999, 1:4000, 1:10) = 0;
for i=1:4999
[IDX(i,:,:), D(i,:,:)] = knnsearch(...
[(tracer_x(i,:))',(tracer_y(i,:))'], ...
[(tracer_x(i,:))', (tracer_y(i,:))'], 'k', 10);
end
and then call it as:
[IDX, D] = neighborsearch(tracer_x, tracer_y);
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!