how to insert a txt file inside a function by using gui

Hi all.Iam having a function like the one given below
v = importdata('myfile.txt'); V1 = v(:,1); v2 = v(:,2);
Here, instead of writing the file name in the program I want to give the file as an input through gui.so I created a gui with a browse button .How do I import the file name into the function
% launch GUI
my_gui;
% get the handle to the GUI and wait for it to be closed
waitfor(my_gui);
% continue with script
Now it is showing me an error. "error in importdata"like this. what should I do now. Help me out

 采纳的回答

Do not leave the GUI. Select a file inside the GUI, store it in the handles struct (see the bunch of threads concerning "share data between callbacks") and use a button like "Open file" to start the import.
Having a GUI, but closing it to start the computations, is not convenient or user friendly. Look how porfessional software works.

更多回答(0 个)

类别

Community Treasure Hunt

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

Start Hunting!

Translated by