Alternative to textread on Linux

4 visualizzazioni (ultimi 30 giorni)
Paul Huter
Paul Huter il 3 Dic 2012
I'm currently using textread to load a text file for later display in an edit field on my GUI. However, I'm in Linux, and discovered memory isn't freed up - so, my program got really slow, and I had to close MATLAB because I keep loading more and more text files. Is there a way to display my text file without loading the whole thing into memory?

Risposta accettata

Walter Roberson
Walter Roberson il 3 Dic 2012
You should be using textscan() instead of textread()
There is no way in MATLAB to display the content of a file in a uicontrol() editbox without loading the file in to memory.
If you set() the String property of the uicontrol to be the cell array of strings, then due to MATLAB's copy-on-write behavior, this will not duplicate the storage of what was read in, only share it (until one of the two locations changes.)
  2 Commenti
Paul Huter
Paul Huter il 3 Dic 2012
I will change to textscan(), but is there a way to clear that memory? The way my code is set up, when a filename is selected, the file is displayed, but if I go from file A to file B and back to file A, file A is loaded twice. I am going to try to come up with a way to only load once, but suggestions are appreciated.
Walter Roberson
Walter Roberson il 3 Dic 2012
The memory is cleared automatically when the variable you read it in to is deleted -and- the String property of the editbox is set to something else.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by