Matlab Crashes When Executing randperm Function
Mostrar comentarios más antiguos
I am running Matlab 2013b.
I have a function that analyzes data. It runs correctly when executed within Jenkins running on Linux. The code takes about an hour to run.
When I run on my Windows PC in a Putty window connected to a Linux box Matlab crashes every time. It crashes when executing the line "var = randperm(N)", where N is a double with a value = 58. I stepped through the code manually and stopped at different points and typed "var = randperm(58)" without any problem. This problem was verified by a second engineer who had run across the same problem weeks before me.
I have no idea how to troubleshoot this problem.
Thanks in advance for any help.
Mike
9 comentarios
Maybe it is worth trying to use round(). It looks like N is computed somewhere inside your code, e.g.
randperm(round(56.00001))
Michael Cappello
el 20 de Feb. de 2024
David Goodmanson
el 21 de Feb. de 2024
Editada: David Goodmanson
el 22 de Feb. de 2024
Hi Sulaymon,
I assume that you are checking the value of N when it crashes on that line (using the debugger although rhere are other ways to accomplish it) and not merely typing
var = randperm(58)
at various spots. If N truly equals 58 it's hard to see how this couId occur. You might also try your own version
function a = randperm1(n)
[~,a] = sort(rand(1,n)); % row vector
end
just to see what happens.
Michael Cappello
el 22 de Feb. de 2024
Jeff Miller
el 22 de Feb. de 2024
Maybe check to make sure that
idx = 1:length(X);
works fine?
Walter Roberson
el 23 de Feb. de 2024
What shows up for
which -all randperm
David Goodmanson
el 23 de Feb. de 2024
It doesn't look to be involved here, but unless a person is 100% sure that x is a row or column vector, some people tend to stay away from the length(x) command, using size(x,n) instead because there is no question of one's intent. The length command gives the max size of x along any of its dimensions, which has been known to lead to unwanted surprises.
Michael Cappello
el 23 de Feb. de 2024
I don't know if this could be the reason, but I had a similar problem with "octave" under Windows 11.
Switching the default console to the “Windows Console Host” solved the problem:
But since you work under MATLAB 2013, you might have to have a much lower Windows version installed.
Respuestas (0)
Categorías
Más información sobre Number Theory 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!