Azzera filtri
Azzera filtri

Passing arguments to gui via varargin is slow - why?

5 visualizzazioni (ultimi 30 giorni)
Hi everyone,
I am using a gui created with GUIDE and I am passing some arguments to the gui via varargin. Varargin is then read during the _OpeningFcn. Part of the gui is plotting a large vector. When I use small variables in the varargin and read the large data from within the _OpeningFcn, everythin works fine. If I pass the large vector as an argument via varargin to the gui, it takes forever (minutes and more). Passing these arrays to other (normal) function works fine, the size is still reasonable (1x75,000,000 double).
Does anyone know why this happens? And does anyone know a solution or workaround? Is using global variables a solution?
Thanks for your ideas!
Maximilian
  2 Commenti
José-Luis
José-Luis il 28 Giu 2016
Could you post a snippet of your code?
Maximilian Rüppell
Maximilian Rüppell il 28 Giu 2016
I just found the reason and I am posting this just in case someone elso is having a similar problem: The inputs of varargin need to explicitly specified, i.e.
wanted_variable=varargin{1};
I was using the varargin with another function to sort the input arguments:
sorted_variables = other_function(varargin);
I think that caused MATLAB to search for something special in the varargin, since according to the profiler almost all time was spent at gui_mainfcn>local_isInvokeHGCallback and the code:
try
fhandle = functions(gui_State.gui_Callback);
result = ~isempty(findstr(gui_State.gui_Name,fhandle.file)) || ...
(ischar(varargin{1}) ...
&& isequal(ishghandle(varargin{2}), 1) ...
&& (~isempty(strfind(varargin{1},[get(varargin{2}, 'Tag'), '_'])) || ...
~isempty(strfind(varargin{1}, '_CreateFcn'))) );
catch
result = false;
end
So, everything works fine again. :-)

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Interactive Control and Callbacks 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