Wait bar or any indication of progress when loading a .mat file

17 次查看(过去 30 天)
Hi,
I am running a GUI that loads a .mat file(500mb) with a single variable. I am wondering if there is anyway to make the loading process faster or simply a way to display loading progress so the user won't be confused and think the GUI crashes.
Thanks,

回答(2 个)

Adam
Adam 2017-1-25
I created my own busy cursor class for things like this (though it just changes the cursor to the windows busy cursor, with some handling of multiple figures being active and putting the cursor on each back to what it was beforehand when it gets deleted).
More simply though I also sometimes just throw up a basic UI that says 'Processing...' or something more relevant to whatever is happening and then close the UI once it is complete. It's not very graceful, but it at least tells the user something is happening rather than them thinking nothing is happening.
  1 个评论
Jan
Jan 2017-1-25
The "more relevant" option would be:
Loading file - please wait some seconds...
or a "minute" depending on how long the reading usually needs. This soultion is used frequently and the users will not be surprised. +1

请先登录,再进行评论。


Walter Roberson
Walter Roberson 2017-1-25
To make the loading process faster, you could move the file onto a SSD (Solid State Drive).
To be able to display loading progress, your options are:
  • make the file binary and read it in chunks using fread(), displaying progress as you go
  • make the file binary and use memmapfile() to access parts of it as needed
  • use a -7.3 mat file and access parts of the variables using matFile() so that you do not need to access all of it at one time
  • if the .mat contains multiple variables, then loop loading one of the variables at a time, displaying progress as you go
  2 个评论
Shih-Hsuan Yuan
Shih-Hsuan Yuan 2017-1-25
These are useful advice, but unfortunately I have no control of the input file format. It is a .mat file with a single variable, which is a list of cells.
Walter Roberson
Walter Roberson 2017-1-25
Then all you can do to make it faster is to move it to ssd or equivalent.
There are no methods provided by Mathworks to be able to get feedback that a load() is progressing. It drops into compiled code, which does service the event queue while it is running. Also because it is a single statement the timer functions are not given an opportunity to run.
The one exception to this that I know of is that if you load a graphics object that has a CreateFcn callback then that callback will be executed during the load, which could potentially give an opportunity to do updates. If you load a figure then there is a brief point where it drops into code at the MATLAB level which could perhaps give a chance for timer functions to run.
It also seems to me that if you load an Object that the constructor might be run; if so then that might be an opportunity for timer functions to execute.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 App Building 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by