-
Notifications
You must be signed in to change notification settings - Fork 3
/
myplotter.m
executable file
·42 lines (30 loc) · 1.38 KB
/
myplotter.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function myplotter
h = figure('Name','My plotter');
axes('position',[0.1 0.1 0.6 0.8]);
grid on;
hold on;
uicontrol('style','text','units','normalized','position',[0.75 0.9 0.1 0.05],'string','Filter:');
uicontrol('style','text','units','normalized','position',[0.75 0.85 0.03 0.05],'string','a =');
uicontrol('style','edit','tag','x_var','units','normalized','position',[0.8 0.85 0.05 0.05],'string','2');
uicontrol('style','text','units','normalized','position',[0.88 0.85 0.03 0.05],'string','b =');
uicontrol('style','edit','tag','y_var','units','normalized','position',[0.93 0.85 0.05 0.05],'string','1');
uicontrol('style','pushbutton','tag','plot_button','callback',@plotcurve,'units','normalized','position',[0.75 0.35 0.1 0.05],'string','Plot');
uicontrol('style','pushbutton','tag','plot_button','callback',@clearaxes,'units','normalized','position',[0.75 0.25 0.1 0.05],'string','Clear');
%Callback function for plotting a curve
function plotcurve(obj,eventdata)
x_tag = findobj('tag','x_var');
y_tag = findobj('tag','y_var');
try
x_var = get(x_tag,'string');
y_var = get(y_tag,'string');
x = evalin('base',x_var);
y = evalin('base',y_var);
plot(x,y)
catch
errordlg('Sorry, could not read and plot data','My plotter');
end
return
%Callback function for clearing the axes
function clearaxes(obj,eventdata)
cla
return;