24 Hours for run my for loop
2 ビュー (過去 30 日間)
Hi guys, I wanted to ask if there is a toolbox or a way to speed up the run of my for loop. I have a 2017 MacBook with 8GB of RAM and my script takes 24 hours to find the results. Is there the possibility of using a machine on the server with a higher ram?
その他の回答 (1 件)
John D'Errico 2022 年 8 月 16 日
The crystal ball is soooo foggy today. I just cannot look into your computer to know why your code is slow. All the darned thing will tell me is that I may come into a large sum of money soon. Or maybe, it is telling me my heirs might do the same thing. Such a foggy crystal ball.
Seriously, we cannot know why your code is slow, so it is impossible to know how to make it run faster. At the same time, your question tends to suggest you are not an expert at MATLAB. And that suggests your code might be inefficiently written.
The very first thing you need to do is to look carefully at your code, using the profiling tools in MATLAB. Look here: profile
What you will be looking to find are bottlenecks in your code. What is costing you time? What lines of code are the problems? Next, look carefully at those lines. Can they be improved? It is often the case that you are doing something inefficiently. So can you improve that line of code?
I would point out that often you can gain some speed by the use of tools like parfor. At the same time, you can often gain orders of magnitude in speed by simply writing efficient code.