Clearing Issues With GUI

5 views (last 30 days)
Adam Cutbill
Adam Cutbill on 28 Jan 2011
Hi,
I'm having issues when running a function from a Guide GUI pushbutton. When I call this function, from a script it runs very quickly. However, if it is called from the GUI , it is very slow. The function (which performs an iterative algorithm) starts very quickly after the press (i.e, I push the button and it begins instantly), but it runs slow. For example, with the script call it takes about 0.1 seconds to complete one iteration, while when called from the GUI it takes about 3 seconds.
I found out if I clear the variables, then re-declare them in the iterative function, it runs very quickly even when called from the GUI:
ie:
func(x,y,z)
clear all
x=5;
y=5;
z=5;
....
This of course defeats the purpose of passing parameters. I'm looking for a way to clear all and keep a few variables. Note, using the Keep function or clearvars except, won't work in this case. I think "Classes" is where I'm getting garbage, not in the variables, but there is no way to add exceptions to "clear classes". I've also tried save, clear, load, but no success. My next attempt is to save to .txt, clear, then load, but this seems inelegant. Any suggestions?

Accepted Answer

Jan
Jan on 28 Jan 2011
The problem is not included inside "func(x,y,z) clear all x=5; y=5; z=5;", but in the other lines. You can use the PROFILEr to inspect where the function wastes the time. Afterwards you could post these lines and asked more specific again.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!