Long runtime when producing the graph

1 次查看(过去 30 天)
Ann
Ann 2020-8-29
评论: Peter O 2020-8-29
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 个评论
Ann
Ann 2020-8-29
Okay, thanks for the advice! You do help me a lot!
Peter O
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:
  1. 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.
  2. 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.
  3. 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 CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by