
Call contents of one pushbutton to be used as content for another push button
    2 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
Dear all,
I tried to import a text file via a pushbutton  in app designer and it works.Now I want to use let's say 1st column of that file into another push button ?
I tried to use it like this but its not recognizing.Attaching the sample part code here.How to link the contents of pushbutton 1 to another ?
Thank you for your help in advance
% Button pushed function: Importfile
        function ImportfilePushed(app, event)
            [file,path] = uigetfile('*.txt');
            T = load(file);
            t1 = T(:,1); t2 = T(:,2); 
            disp (t1)
        end
        % Button pushed function: UNIFORMButton
        function UNIFORMButtonPushed(app, event)
        %columns from the text file
             disp(t1)
        end
2 Kommentare
  Thomas Fournier
      
 am 27 Aug. 2021
				To share Data from one fonction to the other, it has to be stored in a global variable. Global variables are the properties of your app.
you can add some with this button:

For exemple you creates a property t1
After that, in your code, you replace t1 by app.t1 and it should work.
% Button pushed function: Importfile
        function ImportfilePushed(app, event)
            [file,path] = uigetfile('*.txt');
            T = load(file);
            app.t1 = T(:,1); t2 = T(:,2); 
            disp (app.t1)
        end
        % Button pushed function: UNIFORMButton
        function UNIFORMButtonPushed(app, event)
        %columns from the text file
             disp(app.t1)
        end
Antworten (0)
Siehe auch
Kategorien
				Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
			
	Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!