classdef neuerversuch < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        UIFigure     matlab.ui.Figure
        UIAxes       matlab.ui.control.UIAxes
        SliderLabel  matlab.ui.control.Label
        Slider       matlab.ui.control.Slider
    end

    
    properties (Access = private)
        x;
        y;
        SP; % Description
        t;
        c;
        dx;
        dy;
        Punkte;
        % Description
        v;
        % Description
        s; % Description
    end

    methods (Access = private)

        % Code that executes after component creation
        function startupFcn(app)
            app.UIAxes.XLimMode = 'manual';
            app.UIAxes.YLimMode = 'manual';
            app.UIAxes.Position = [10 10 600 430];
            app.UIAxes.XLim = [0 500];
            app.UIAxes.YLim = [200 400];
            hold(app.UIAxes)
            
            
            load Werte.mat
            app.s = length(points);
            app.x = points(1,1:app.s);
            app.y = points(2,1:app.s);
            plot(app.UIAxes,app.x,app.y,'-b');
            hold(app.UIAxes);
        end

        % Callback function
        function AnzahlderzuInterpolierendenPunkteSpinnerValueChanging(app, event)
       %alternative zum slider
        end

        % Value changing function: Slider
        function SliderValueChanging(app, event)
                    n = event.Value; %  Anzahl der zu interpolierenden Punkte auswählen
           
            app.t = 1:1:app.s;
            app.c = 1:0.0005:app.s;
               
              hold(app.UIAxes);
          app.dx = spline(app.t,app.x,app.c);% hier müsste irgendwie die Abhängigkeit n hin oder?
                app.dy = spline(app.t,app.y,app.c);
            app.SP = plot(app.UIAxes,app.dx,app.dy,'black');
            hold(app.UIAxes);
           
           
           %app.Punkte= plot(app.UIAxes,app.x,app.y,'o') % soll n- interpolierte punkte plotten 
           % drawnow limitrate
        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 640 480];
            app.UIFigure.Name = 'UI Figure';

            % Create UIAxes
            app.UIAxes = uiaxes(app.UIFigure);
            title(app.UIAxes, 'Title')
            xlabel(app.UIAxes, 'X')
            ylabel(app.UIAxes, 'Y')
            app.UIAxes.XTick = [0 50 100 150 200 250 300 350 400 450 500];
            app.UIAxes.XTickLabel = {'0'; '50'; '100'; '150'; '200'; '250'; '300'; '350'; '400'; '450'; '500'};
            app.UIAxes.YTick = [0 50 100 150 200 250 300 350 400 450 500];
            app.UIAxes.YTickLabel = {'0'; '50'; '100'; '150'; '200'; '250'; '300'; '350'; '400'; '450'; '500'};
            app.UIAxes.Position = [184 121 300 185];

            % Create SliderLabel
            app.SliderLabel = uilabel(app.UIFigure);
            app.SliderLabel.HorizontalAlignment = 'right';
            app.SliderLabel.Position = [99 404 36 22];
            app.SliderLabel.Text = 'Slider';

            % Create Slider
            app.Slider = uislider(app.UIFigure);
            app.Slider.Limits = [0 65];
            app.Slider.MajorTicks = [0 5 10 15 20 25 30 35 40 45 50 55 60 65];
            app.Slider.ValueChangingFcn = createCallbackFcn(app, @SliderValueChanging, true);
            app.Slider.MinorTicks = [0 5 10 15 20 25 30 35 40 45 50 55 60 65];
            app.Slider.Position = [156 413 405 3];
        end
    end

    methods (Access = public)

        % Construct app
        function app = neuerversuch

            % Create and configure components
            createComponents(app)

            % Register the app with App Designer
            registerApp(app, app.UIFigure)

            % Execute the startup function
            runStartupFcn(app, @startupFcn)

            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