Long runtime when producing the graph
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi. I’m new here.
I’m working with importing data from MS Excel and make it in a almost a thousand lines of coding. Because I directly use data from MS Excel. Normally it takes up to 15 minute to produce the graph. Currently I’m using processor i5, RAM 12gb and hdd 1tb. Anyone can suggest for me what best way to cut down the time producing the graph? Maybe upgrade to ssd or upgrade another RAM? Or should I transfer everything in table form and not to use in MS Excel anymore?
Thank you in advanced.
댓글 수: 5
Peter O
2020년 8월 29일
Mario's suggestion on the profiler command will help you a lot.
A couple tips for common issues with I/O to look for:
- A FOR loop that repeatedly calls an import function. If you're accessing a couple thousand rows and you're importing one row at a time, you're opening and closing a file on disk each time the loop executes. It's much more efficient to access the file on disk once, read everything into memory, and manipulate from there. At a minimum, you want to minimize the open/close operations. MATLAB's I/O functions have a lot of flexibility on how to get data out of a file, so check out their documentation.
- If you haven't already, take a look at how the Import Data function is structured. Use the command from the toolbar on one of your spreadsheets and then hit the "Generate Code" dropdown to make a script or function. It might help you improve your programmatic file access method.
- Preallocation of data array space. The profiler will catch this, but if you're reading into memory and growing the array each time, then you're asking the computer to search for larger and larger chunks of memory each time, rather than just reserve one big chunk once.
And if the import is fast, it might be in the plot, though I think that's a little less likely, but with a lot of internal graphics objects to render, the plot tools can slow down. Are you trying to trying to put a million points on the chart? Or a couple hundred individual lines?
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!