Thread Subject: Load mat-file from GUI

Subject: Load mat-file from GUI

From: Diego Orlando Barragan Guerrero

Date: 13 Oct, 2010 21:52:03

Message: 1 of 4

Hi all

I try to load a mat-file when I close GUI.

I use this code:

function figure1_DeleteFcn(hObject, eventdata, handles)
load test2.mat

But in WS nothing appear.

Kind regards.
 

Subject: Load mat-file from GUI

From: Diego Orlando Barragan Guerrero

Date: 13 Oct, 2010 22:17:04

Message: 2 of 4

I do it:

function figure1_DeleteFcn(hObject, eventdata, handles)
    % Cargar archivo.mat
    load test2.mat
    % Excluir variables de la GUI
    no={'eventdata','hObject','handles'};
    % Leer archivo .mat
    s = whos('-file', 'test2');
    % Asignar nombre y variable
    for n=1:length(s)
        if strcmp(s(1).name,char(no{1})) || strcmp(s(1).name,char(no{2})) || strcmp(s(1).name,char(no{3}))
            continue
        end
        % Grabar en workspace
        assignin('base', s(n).name, eval(s(n).name))
    end


=)

Subject: Load mat-file from GUI

From: Camron Call

Date: 13 Oct, 2010 22:31:04

Message: 3 of 4

It might be that when you load the mat file, you aren't loading them into the right workspace. If you call load from within a function, it will load the variables into the workspace of that function. Then when that function returns, it's variables are deleted.

Subject: Load mat-file from GUI

From: ImageAnalyst

Date: 14 Oct, 2010 00:17:07

Message: 4 of 4

I agree with Camron. You load them in inside your function and then
they are local variables at that point - local to that function ONLY.
When that function returns or exits, those variables vanish. You will
need to load them again in the scope of the function where you want to
use them, or from the command line or a simple script if you want to
keep them hanging around.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
gui Diego Orlando 13 Oct, 2010 17:54:19
workspace Diego Orlando 13 Oct, 2010 17:54:19
load Diego Orlando 13 Oct, 2010 17:54:19
rssFeed for this Thread

Contact us at files@mathworks.com