MATLAB Answers

Creating an interface with Guide

1 view (last 30 days)
How to insert in Matlab code for example the data of a vector in function of time to create an immage with the icon "axes"?
for example a vector h = [67, 32, 67, 87, 45, 89];
time : t = 1:6;
when I use Guide, then Blank GUI, then Axes, I have this general code:
function varargout = untitled1(varargin)
% UNTITLED1 MATLAB code for untitled1.fig
% UNTITLED1, by itself, creates a new UNTITLED1 or raises the existing
% singleton*.
%
% H = UNTITLED1 returns the handle to a new UNTITLED1 or the handle to
% the existing singleton*.
%
% UNTITLED1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED1.M with the given input arguments.
%
% UNTITLED1('Property','Value',...) creates a new UNTITLED1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled1_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 untitled1
% Last Modified by GUIDE v2.5 18-Aug-2019 19:28:36
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled1_OpeningFcn, ...
'gui_OutputFcn', @untitled1_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 untitled1 is made visible.
function untitled1_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 untitled1 (see VARARGIN)
% Choose default command line output for untitled1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled1_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 (seguie GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
How to insert my new data to create that interface??

  3 Comments

Adam Danz
Adam Danz on 18 Aug 2019
Does your GUI already have an axis for plotting? If not, you have to open your GUI from GUIDE and add one.
Where is the data coming from? If it's produced and loaded from within the GUI, you can plot it directly,
plot(GUIaxis, t, h)
% ^^^^^^^this is the handle to your GUI axis
Enrica Brunetti
Enrica Brunetti on 18 Aug 2019
How to create an axis for plotting from Guide?
The data is imported as new variable in matlab code.

Sign in to comment.

Accepted Answer

Bhargavi Maganuru
Bhargavi Maganuru on 21 Aug 2019
You can add following code in OpeningFcn callback for creating a plot
h = [67, 32, 67, 87, 45, 89];
t = 1:6;
axes(handles.axes1);
plot(t,h);

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.