Filter löschen
Filter löschen

GUI load file.mat and use it

4 Ansichten (letzte 30 Tage)
MartinM
MartinM am 23 Jan. 2020
Kommentiert: Stephen23 am 24 Jan. 2020
Hi,
I am creating a GUI and need to use data from m.file. It's working for the first file, but not or the second. Both are (double). Any idea?
matrice_losses.mat is load, but not MM...
Regards
  5 Kommentare
Jakob B. Nielsen
Jakob B. Nielsen am 24 Jan. 2020
It is possible that you can load matrice_losses because you subsequently "do something" to it, either inside your function or elsewhere in the code. That means it is a nested variable within your GUI workspace (I dont know the correct terms, sorry ;)
MM, however, is just loaded and done nothing with. Try initializing MM outside the function, or calling it from another function in the GUI.
I'm just spitballing here. If one thing can load, another should be able to, and this is the only difference I can see out of what you posted.
Stephen23
Stephen23 am 24 Jan. 2020
Bad code practices strike again!
You can easily avoid this error by loading into an output variable (which you should be doing anyway), e.g.:
S = load('matrice_losses.mat');
lamfit = S.matrice_losses(:,1).*1e-3;
lossdB = S.matrice_losses(:,2);

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jose Jeremias Caballero
Jose Jeremias Caballero am 24 Jan. 2020
Bearbeitet: Jose Jeremias Caballero am 24 Jan. 2020
function PushB(hObject,eventdata,handles)
load matrice_losses
lamfit=(matrice_losses(:,1).*1e-3)
lossdB =matrice_losses(:,2);
u=load('MM.mat')
mm=u.mm
end

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by