matlab says busy but isn't doing anything while running a script
Mostrar comentarios más antiguos
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 comentarios
Adam
el 26 de Jun. de 2015
How do you know it isn't doing anything?
Without looking too deeply at your code I imagine it is processing, but you are giving it a large amount to do so it takes a long time. Neighbourhood searches are often slow, especially if not programmed with any optimisations.
Carrie Elliott
el 26 de Jun. de 2015
Adam
el 26 de Jun. de 2015
Well they wouldn't be unless you have a breakpoint set as that is a function. The matrices will go out of scope when it completes and only 'filename' would be returned, except that doesn't appear to be assigned in the function so unless you have only posted a small part of the function it should crash at that point.
Carrie Elliott
el 26 de Jun. de 2015
Image Analyst
el 26 de Jun. de 2015
Editada: Image Analyst
el 26 de Jun. de 2015
Like Adam said, you never assigned anything for filename so if you ever got to the point where the function exited, it would throw an error because you never assigned filename as the function declaration
function filename = neighborsearch(tracer_x,tracer_y)
requires. Also, if we're to run this, you must tell us what values you supplied for tracer_x and tracer_y. How else can we reproduce what you did?????
Carrie Elliott
el 26 de Jun. de 2015
Image Analyst
el 26 de Jun. de 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
el 26 de Jun. de 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.)
Respuestas (1)
Kelly Kearney
el 26 de Jun. de 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);
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!