help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a graphical user interface with OCTAVE?


From: Doug Stewart
Subject: Re: Creating a graphical user interface with OCTAVE?
Date: Fri, 27 May 2016 15:14:28 -0400



On Fri, May 27, 2016 at 1:19 PM, shank1207 <address@hidden> wrote:
hello thanks for the reply this capabilities looks cool but i was trying to
do this code which works in MATLAB but i am not getting the result do i need
to change the syntax?

function GUI_slider
clc
clear

%// Create GUI controls
handles.figure = figure('Position',[100 100 500 500],'Units','Pixels');

handles.axes1 = axes('Units','Pixels','Position',[60,100,400,300]);

handles.Slider1 = uicontrol('Style','slider','Position',[60 20 400
50],'Min',0,'Max',1,'SliderStep',[.1 .1],'Callback',@SliderCallback);

handles.Edit1 = uicontrol('Style','Edit','Position',[250 450 100
20],'String','Update Me');
handles.Text1 = uicontrol('Style','Text','Position',[180 450 60
20],'String','Slider Value');

handles.xrange = 1:20; %// Use to generate dummy data to plot.

guidata(handles.figure,handles); %// Update the handles structure.

    function SliderCallback(~,~) %// This is the slider callback, executed
when you release the it or press the arrows at each extremity.

        handles = guidata(gcf);

        SliderValue = get(handles.Slider1,'Value');
        set(handles.Edit1,'String',num2str(SliderValue));

        plot(handles.xrange,SliderValue*rand(1,20),'Parent',handles.axes1);
    end

end






to make this work you need to make 2 M files
the first one would be GUI_slider.m
and the second one would be SliderCallback.m

put the following code in the second file and take it out of the first file.

  function SliderCallback(~,~) %// This is the slider callback, executed
when you release the it or press the arrows at each extremity.

        handles = guidata(gcf);

        SliderValue = get(handles.Slider1,'Value');
        set(handles.Edit1,'String',num2str(SliderValue));

        plot(handles.xrange,SliderValue*rand(1,20),'Parent',handles.axes1);
    end


It then works for me.


--
DAS


reply via email to

[Prev in Thread] Current Thread [Next in Thread]