MATLAB: Plotting data in gui

guiguidematlab gui

Hi all!
I am trying to plot this code in gui:
function varargout = demo6(varargin)
% DEMO6 MATLAB code for demo6.fig
% DEMO6, by itself, creates a new DEMO6 or raises the existing
% singleton*.
%
% H = DEMO6 returns the handle to a new DEMO6 or the handle to
% the existing singleton*.
%
% DEMO6('CALLBACK',hObject,eventData,handles,…) calls the local
% function named CALLBACK in DEMO6.M with the given input arguments.
%
% DEMO6('Property','Value',…) creates a new DEMO6 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before demo6_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to demo6_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help demo6
% Last Modified by GUIDE v2.5 28-Jul-2019 20:41:07
% Begin initialization code – DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, …
'gui_Singleton', gui_Singleton, …
'gui_OpeningFcn', @demo6_OpeningFcn, …
'gui_OutputFcn', @demo6_OutputFcn, …
'gui_LayoutFcn', [] , …
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code – DO NOT EDIT
% — Executes just before demo6 is made visible.
function demo6_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to demo6 (see VARARGIN)
% Choose default command line output for demo6
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes demo6 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% — Outputs from this function are returned to the command line.
function varargout = demo6_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% — Executes on button press in plot1.
function plot1_Callback(hObject, eventdata, handles)
% hObject handle to plot1 (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handle.axes1)
time= 0:1:40;
case1t5= [5 6 9 14 21 30 41 54 69 86 105 126 149 174 201 230 261 294 329 366 405 446 489 534 581 630 681 734 789 846 905 966 1029 1094 1161 1230 1301 1374 1449 1526 1605];
plot(time,case1t5)
title('case1 temp 5');
xlabel('time')
ylabel('output');
guidata(hObject, handles);
However, I get this erorr code:
The class handle has no Constant property or Static method named 'axes1'.
Error in demo6>plot1_Callback (line 81)
axes(handle.axes1)
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in demo6 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)demo6('plot1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

Best Answer

axes(handles.axes1)
Notice you had handle instead of handles
Related Question