classdef app3 < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        UIFigure                    matlab.ui.Figure
        BrowseButton                matlab.ui.control.Button
        NomduFichierEditFieldLabel  matlab.ui.control.Label
        NomduFichierEditField       matlab.ui.control.EditField
        figure2axesButton           matlab.ui.control.Button
        figure3axesButton           matlab.ui.control.Button
    end


    properties (Access = private)
        x_data
        y_data
        z_data
    end


    methods (Access = private)

        % Button pushed function: BrowseButton
        function BrowseButtonPushed(app, event)
         [filename, path]=uigetfile();
         app.NomduFichierEditField.Value= filename;   
         figure(app.UIFigure);
        end

        % Value changed function: NomduFichierEditField
        function NomduFichierEditFieldValueChanged(app, event)
            value = app.NomduFichierEditField.Value;
        end

        % Button pushed function: figure2axesButton
        function figure2axesButtonPushed(app, event)
        d=load(app.NomduFichierEditField.Value,'-mat');
        series= d.hgS_070000.children(1).children(1);
        app.x_data = series.properties.XData;
        app.y_data = series.properties.YData;
        
        
        fid = fopen('Données_2_axes.txt','w');
       
         fprintf(fid,'%s\n','vecteur x');
        
        fprintf(fid,'%i\t',app.x_data);
        
        
        fprintf(fid,'\n%s\n','vecteur y');
        
        
        fprintf(fid,'%i\t',app.y_data);
       
        fclose(fid);
        end

        % Button pushed function: figure3axesButton
        function figure3axesButtonPushed(app, event)
        d=load(app.NomduFichierEditField.Value,'-mat');
        series= d.hgS_070000.children(1).children(1);
        app.x_data = series.properties.XData;
        app.y_data = series.properties.YData;
        app.z_data = series.properties.ZData;   
        
        A=size(app.x_data);
        B=size(app.y_data);
        
        fid = fopen('Données_x_y.txt','w');
        
        fprintf(fid,'%s\n','vecteur x');
        
        fprintf(fid,'%i\t',app.x_data);
      
        
        fprintf(fid,'\n%s\n','vecteur y');
        
        fprintf(fid,'%i\t',app.y_data);
        
        fclose(fid);
        
        fide = fopen('Matrice_z.txt','w');
        
        fprintf(fide,'%s\n','Matriec z');
        for i=1:B(1,2)
            for t=1:A(1,2)
                fprintf(fide,'%i\t',app.z_data(i,t));
            end
            fprintf(fide,'\n');
        end
        
        fclose(fide);
        end
    end

    % App initialization and construction
    methods (Access = private)

        % Create UIFigure and components
        function createComponents(app)

            % Create UIFigure
            app.UIFigure = uifigure;
            app.UIFigure.Position = [100 100 527 177];
            app.UIFigure.Name = 'UI Figure';

            % Create BrowseButton
            app.BrowseButton = uibutton(app.UIFigure, 'push');
            app.BrowseButton.ButtonPushedFcn = createCallbackFcn(app, @BrowseButtonPushed, true);
            app.BrowseButton.FontWeight = 'bold';
            app.BrowseButton.FontAngle = 'italic';
            app.BrowseButton.Position = [21 58 102 22];
            app.BrowseButton.Text = 'Browse';

            % Create NomduFichierEditFieldLabel
            app.NomduFichierEditFieldLabel = uilabel(app.UIFigure);
            app.NomduFichierEditFieldLabel.HorizontalAlignment = 'right';
            app.NomduFichierEditFieldLabel.Position = [21 121 87 22];
            app.NomduFichierEditFieldLabel.Text = 'Nom du Fichier';

            % Create NomduFichierEditField
            app.NomduFichierEditField = uieditfield(app.UIFigure, 'text');
            app.NomduFichierEditField.ValueChangedFcn = createCallbackFcn(app, @NomduFichierEditFieldValueChanged, true);
            app.NomduFichierEditField.Position = [123 121 365 22];

            % Create figure2axesButton
            app.figure2axesButton = uibutton(app.UIFigure, 'push');
            app.figure2axesButton.ButtonPushedFcn = createCallbackFcn(app, @figure2axesButtonPushed, true);
            app.figure2axesButton.FontWeight = 'bold';
            app.figure2axesButton.FontAngle = 'italic';
            app.figure2axesButton.Position = [404 58 100 22];
            app.figure2axesButton.Text = 'figure à 2 axes';

            % Create figure3axesButton
            app.figure3axesButton = uibutton(app.UIFigure, 'push');
            app.figure3axesButton.ButtonPushedFcn = createCallbackFcn(app, @figure3axesButtonPushed, true);
            app.figure3axesButton.FontWeight = 'bold';
            app.figure3axesButton.FontAngle = 'italic';
            app.figure3axesButton.Position = [208 58 100 22];
            app.figure3axesButton.Text = 'figure à 3 axes';
        end
    end

    methods (Access = public)

        % Construct app
        function app = app3

            % Create and configure components
            createComponents(app)

            % Register the app with App Designer
            registerApp(app, app.UIFigure)

            if nargout == 0
                clear app
            end
        end

        % Code that executes before app deletion
        function delete(app)

            % Delete UIFigure when app is deleted
            delete(app.UIFigure)
        end
    end
end