function CalcGUI
%Function CALCGUI. Integral and Derivative Functions GUI.
% CALCGUI shows the first and second derivatives of the primary functions
% f(x) and g(x) as well as the area from the lower to upper bounds of the
% primary functions. It also displays the equations of the first and
% second derivatives and the area displayed.
close all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Constant Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hFigColor=[0.6 0.6 0.6];
xyPanColor=[0 0.7 0];
fPanColor=[0.2 0.4 1];
gPanColor=[1 0.2 0.1];
EditColor=[0.95 0.95 0.95];
InstructColor=[0.75 0.75 0.75];
numpts=500;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%% Instructions Window %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
InstructFigure=figure(...
'Units','Pixels',...
'Position',[0 38 300 850],...
'MenuBar','None',...
'NumberTitle','off',...
'Color',InstructColor,...
'Name','Instruction for Calculator');
Instructions0='Instructions for Calculator';
Instructions1='Calculator is used to calculate the Symbolic first and second derivatives of two single-variable functions. Calculator also graphs the primary functions, its first and second derivatives, and the definite integral (area under the curve from the lower to upper bounds) on the given axes. CalcGUI allows for two simultaneous equations to be acted upon.';
Instructions2='Using the Primary Function panels.';
Instructions3='Enter the primary equation into the Edit Rectangle (nearly-white). After doing so, you may show the graph of the entered function on the axes by pushing the Radio Button above and to the left of your equation. ***Note: The equation MUST be a single-variable equation.';
Instructions4='Using the 1st and 2nd Derivatives panels.';
Instructions5='After entering an equation into the Primary Function panel above, you can calculate and show the first and second derivatives of the primary function. Pushing the Radio button next to f`(x) will display the first derivative of the primary function and graph it. Pushing the Radio button next to f``(x) will calculate and graph the second derivative of the primary function. Pressing either Radio button again will recalculate the derivative and remove the graph. ';
Instructions6='Using the Definite Integral panels.';
Instructions7='After entering an equation into the Primary Function panel above, you can calculate and show the definite integral of the primary function. First, enter both Lower and Upper Bounds to integrate. When you push the ''Calculate Area'' button, the definite integral of the primary function from the Lower Bound to the Upper Bound will be displayed in the rectangle above the button. Pressing the Radio button will display the area under the curve between the lower and upper bounds, representing the area attained.';
InstructText0=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 825 290 25],...
'String',Instructions0,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor,...
'FontWeight','Bold',...
'FontSize',14);
InstructText1=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 680 290 135],...
'String',Instructions1,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor);
InstructText2=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 650 290 20],...
'String',Instructions2,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor,...
'FontWeight','Bold');
InstructText3=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 523 290 125],...
'String',Instructions3,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor);
InstructText4=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 493 290 20],...
'String',Instructions4,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor,...
'FontWeight','Bold');
InstructText5=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 303 290 190],...
'String',Instructions5,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor);
InstructText6=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 274 290 20],...
'String',Instructions6,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor,...
'FontWeight','Bold');
InstructText7=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 75 290 200],...
'String',Instructions7,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Main Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Primary Figure Window
hFigure=figure(...
'Units','Pixels',...
'Position',[308 38 1200 800],...
'Color',hFigColor,...
'MenuBar','None',...
'NumberTitle','off',...
'Name','CalcGUI');
%Axes
hAxes=axes(...
'Parent',hFigure,...
'Units','Pixels',...
'Position',[300 150 600 600],...
'XGrid','on',...
'YGrid','on',...
'XLim',[-10 10],...
'YLim',[-10,10]);
%Title
hTitle=uicontrol(...
'Style','Text',...
'Units','Pixels',...
'Parent',hFigure,...
'Position',[300 750 600 30],...
'BackgroundColor',hFigColor,...
'String','Single Variable Calculus Calculator with 2 Functions',...
'FontSize',16,...
'HorizontalAlignment','Center');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Image Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This creates the 'background' axes
ImAxes=axes(...
'Parent',hFigure,...
'Units','Normalized',...
'Position',[0 0 1 1]);
% Move the background axes to the bottom
uistack(ImAxes,'bottom');
% Load in a background image and display it using the correct colors
% The image used below, is in the Image Processing Toolbox. If you do not have %access to this toolbox, you can use another image file instead.
I=imread('ConTrail.png');
Im=imagesc(I);
colormap gray
% Turn the handlevisibility off so that we don't inadvertently plot into the axes again
% Also, make the axes invisible
set(ImAxes,...
'handlevisibility','off', ...
'visible','off');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Line Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Line Setup
fLine=line();
set(fLine,...
'XData',[],...
'YData',[],...
'LineStyle','none',...
'LineWidth',2,...
'Color','b');
ffLine=line();
set(ffLine,...
'XData',[],...
'YData',[],...
'LineStyle','none',...
'LineWidth',2,...
'Color','b');
fffLine=line();
set(fffLine,...
'XData',[],...
'YData',[],...
'LineStyle','none',...
'LineWidth',2,...
'Color','b');
gLine=line();
set(gLine,...
'XData',[],...
'YData',[],...
'LineStyle','none',...
'LineWidth',2,...
'Color','r');
ggLine=line();
set(ggLine,...
'XData',[],...
'YData',[],...
'LineStyle','none',...
'LineWidth',2,...
'Color','r');
gggLine=line();
set(gggLine,...
'XData',[],...
'YData',[],...
'LineStyle','none',...
'LineWidth',2,...
'Color','r');
xaxis=line([-1000000,1000000],[0,0],...
'Color','k',...
'LineWidth',1.3);
yaxis=line([0,0],[-1000000,1000000],...
'Color','k',...
'LineWidth',1.3);
hold on
areaf=area(0);
set(areaf,'YData',0,...
'EdgeColor','none',...
'FaceColor','none');
areag=area(0);
set(areag,'YData',0,...
'EdgeColor','none',...
'FaceColor','none');
hold off
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% xyLims Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%X and Y Limits Panel
xyPanel=uipanel(...
'Parent',hFigure,...
'Units','Pixels',...
'Position',[300 20 600 100],...
'BackgroundColor',xyPanColor);
%xy xMin Text: X Min
xMinText=uicontrol(...
'Style','Text',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[10 60 60 25],...
'BackgroundColor',xyPanColor,...
'String','X Min: ',...
'HorizontalAlignment','Left',...
'FontSize',12);
%xy xMin Edit
xMinEdit=uicontrol(...
'Style','Edit',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[80 60 200 25],...
'String','-10',...
'HorizontalAlignment','Left',...
'FontSize',8,...
'Callback',@xMin_Callback);
%xy xMax Text: X Max
xMaxText=uicontrol(...
'Style','Text',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[10 15 60 25],...
'BackgroundColor',xyPanColor,...
'String','X Max: ',...
'HorizontalAlignment','Left',...
'FontSize',12);
%xy xMax Edit
xMaxEdit=uicontrol(...
'Style','Edit',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[80 15 200 25],...
'String','10',...
'HorizontalAlignment','Left',...
'FontSize',8,...
'Callback',@xMax_Callback);
%xy yMin Text: Y Min
yMinText=uicontrol(...
'Style','Text',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[310 60 60 25],...
'BackgroundColor',xyPanColor,...
'String','Y Min: ',...
'HorizontalAlignment','Left',...
'FontSize',12);
%xy yMin Edit
yMinEdit=uicontrol(...
'Style','Edit',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[380 60 200 25],...
'String','-10',...
'HorizontalAlignment','Left',...
'FontSize',8,...
'Callback',@yMin_Callback);
%xy yMax Text: Y Max
yMaxText=uicontrol(...
'Style','Text',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[310 15 60 25],...
'BackgroundColor',xyPanColor,...
'String','Y Max: ',...
'HorizontalAlignment','Left',...
'FontSize',12);
%xy yMax Edit
yMaxEdit=uicontrol(...
'Style','Edit',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[380 15 200 25],...
'String','10',...
'HorizontalAlignment','Left',...
'FontSize',8,...
'Callback',@yMax_Callback);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% f(x) Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%fPanel
fPanel=uipanel(...
'Parent',hFigure,...
'Units','Pixels',...
'Position',[30 150 240 600],...
'BackgroundColor',fPanColor);
%%%%%%%%%%%%%%% f(x) Primary Function %%%%%%%%%%%%%%%
%f(x) Primary Function Panel
fFcnPanel=uipanel(...
'Parent',fPanel,...
'Units','Pixels',...
'Position',[10 490 220 100],...
'BackgroundColor',fPanColor);
%f(x) Text: Primary Function f(x)
fFcnTitleText=uicontrol(...
'Style','Text',...
'Parent',fFcnPanel,...
'Units','Pixels',...
'Position',[10 60 200 30],...
'BackgroundColor',fPanColor,...
'String','Primary Function f(x)',...
'HorizontalAlignment','Center',...
'FontSize',12);
%f(x) Text f(x)=
fFcnText=uicontrol(...
'Style','Text',...
'Parent',fFcnPanel,...
'Units','Pixels',...
'Position',[33 33 30 30],...
'BackgroundColor',fPanColor,...
'String','f(x)=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f(x) Radio Button
fFcnRadio=uicontrol(...
'Style','Radio',...
'Parent',fFcnPanel,...
'Units','Pixels',...
'Position',[10 45 20 20],...
'BackgroundColor',fPanColor,...
'Callback',@fFcnShg_Callback);
%f(x) Edit f(x)
fFcn=uicontrol(...
'Style','Edit',...
'Parent',fFcnPanel,...
'Units','Pixels',...
'Position',[10 10 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Left',...
'FontSize',8);
%%%%%%%%%%%%%%% f(x) Derivatives %%%%%%%%%%%%%%%
%f(x) Derivative Panel
fDerivPanel=uipanel(...
'Parent',fPanel,...
'Units','Pixels',...
'Position',[10 300 220 180],...
'BackgroundColor',fPanColor);
%f(x) Text: 1st and 2nd Derivatives
fDerivTitleText=uicontrol(...
'Style','Text',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[10 140 200 30],...
'BackgroundColor',fPanColor,...
'String','1st and 2nd Derivatives',...
'HorizontalAlignment','Center',...
'FontSize',12);
%f`(x) Text f`(x)=
fDerivText=uicontrol(...
'Style','Text',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[33 118 45 20],...
'BackgroundColor',fPanColor,...
'String','f`(x)=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f`(x) Radio Button
fDerivRadio=uicontrol(...
'Style','Radio',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[10 120 20 20],...
'BackgroundColor',fPanColor,...
'Callback',@fDerivShg_Callback);
%f`(x) f`(x) Text
fDeriv=uicontrol(...
'Style','Text',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[10 85 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Center',...
'FontSize',8,...
'Callback',@fDeriv_Callback);
%f``(x) Text f``(x)=
fDeriv2Text=uicontrol(...
'Style','Text',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[33 53 45 20],...
'BackgroundColor',fPanColor,...
'String','f``(x)=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f``(x) Radio Button
fDeriv2Radio=uicontrol(...
'Style','Radio',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[10 55 20 20],...
'BackgroundColor',fPanColor,...
'Callback',@fDeriv2Shg_Callback);
%f``(x) f``(x) Text
fDeriv2=uicontrol(...
'Style','Text',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[10 20 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Center',...
'FontSize',8,...
'Callback',@fDeriv2_Callback);
%%%%%%%%%%%%%%% f(x) Integrals %%%%%%%%%%%%%%%
%f(x) Integral Panel
fIntPanel=uipanel(...
'Parent',fPanel,...
'Units','Pixels',...
'Position',[10 10 220 280],...
'BackgroundColor',fPanColor);
%f(x) Text: Definite Integral of f(x)
fIntTitleText=uicontrol(...
'Style','Text',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[10 240 200 30],...
'BackgroundColor',fPanColor,...
'String','Definite Integral of f(x)',...
'HorizontalAlignment','Center',...
'FontSize',12);
%f(x) Text: Lower Bound
fIntLowText=uicontrol(...
'Style','Text',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[10 190 80 30],...
'BackgroundColor',fPanColor,...
'String','Lower Bound:',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f(x) Edit Lower Bound
fIntLowEdit=uicontrol(...
'Style','Edit',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[90 200 120 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f(x) Text: Upper Bound
fIntUpText=uicontrol(...
'Style','Text',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[10 140 80 30],...
'BackgroundColor',fPanColor,...
'String','Upper Bound:',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f(x) Edit Upper Bound
fIntUpEdit=uicontrol(...
'Style','Edit',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[90 150 120 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f(x) Text: Area=
fIntAreaText=uicontrol(...
'Style','Text',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[10 90 200 40],...
'BackgroundColor',fPanColor,...
'String','Area Under f(x) from the Lower to Upper Bound=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f(x) Area Text
fIntArea=uicontrol(...
'Style','Text',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[10 60 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Center',...
'FontSize',8);
%f(x) Area Radio Button
fShowAreaRadio=uicontrol(...
'Style','Radio',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[10 20 20 20],...
'BackgroundColor',fPanColor,...
'Callback',@fIntRadio_Callback);
%f(x) Area Push Button
fShowAreaPush=uicontrol(...
'Style','Push',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[30 15 180 30],...
'BackgroundColor',fPanColor,...
'String','Calculate Area',...
'Callback',@fIntShowArea_Callback);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% g(x) Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%gPanel
gPanel=uipanel(...
'Parent',hFigure,...
'Units','Pixels',...
'Position',[930 150 240 600],...
'BackgroundColor',gPanColor);
%%%%%%%%%%%%%%% g(x) Primary Function %%%%%%%%%%%%%%%
%g(x) Primary Function Panel
gFcnPanel=uipanel(...
'Parent',gPanel,...
'Units','Pixels',...
'Position',[10 490 220 100],...
'BackgroundColor',gPanColor);
%g(x) Text: Primary Function g(x)
gFcnTitleText=uicontrol(...
'Style','Text',...
'Parent',gFcnPanel,...
'Units','Pixels',...
'Position',[10 60 200 30],...
'BackgroundColor',gPanColor,...
'String','Primary Function g(x)',...
'HorizontalAlignment','Center',...
'FontSize',12);
%g(x) Text g(x)=
gFcnText=uicontrol(...
'Style','Text',...
'Parent',gFcnPanel,...
'Units','Pixels',...
'Position',[33 33 30 30],...
'BackgroundColor',gPanColor,...
'String','g(x)=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g(x) Radio Button
gFcnRadio=uicontrol(...
'Style','Radio',...
'Parent',gFcnPanel,...
'Units','Pixels',...
'Position',[10 45 20 20],...
'BackgroundColor',gPanColor,...
'Callback',@gFcnShg_Callback);
%g(x) Edit g(x)
gFcn=uicontrol(...
'Style','Edit',...
'Parent',gFcnPanel,...
'Units','Pixels',...
'Position',[10 10 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Left',...
'FontSize',8);
%%%%%%%%%%%%%%% g(x) Derivatives %%%%%%%%%%%%%%%
%g(x) Derivative Panel
gDerivPanel=uipanel(...
'Parent',gPanel,...
'Units','Pixels',...
'Position',[10 300 220 180],...
'BackgroundColor',gPanColor);
%g(x) Text: 1st and 2nd Derivatives
gDerivTitleText=uicontrol(...
'Style','Text',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[10 140 200 30],...
'BackgroundColor',gPanColor,...
'String','1st and 2nd Derivatives',...
'HorizontalAlignment','Center',...
'FontSize',12);
%g`(x) Text g`(x)=
gDerivText=uicontrol(...
'Style','Text',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[33 118 45 20],...
'BackgroundColor',gPanColor,...
'String','g`(x)=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g`(x) Radio Button
gDerivRadio=uicontrol(...
'Style','Radio',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[10 120 20 20],...
'BackgroundColor',gPanColor,...
'Callback',@gDerivShg_Callback);
%g`(x) g`(x) Text
gDeriv=uicontrol(...
'Style','Text',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[10 85 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Center',...
'FontSize',8);
%g``(x) Text g``(x)=
gDeriv2Text=uicontrol(...
'Style','Text',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[33 53 45 20],...
'BackgroundColor',gPanColor,...
'String','g``(x)=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g``(x) Radio Button
gDeriv2Radio=uicontrol(...
'Style','Radio',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[10 55 20 20],...
'BackgroundColor',gPanColor,...
'Callback',@gDeriv2Shg_Callback);
%g``(x) g``(x) Text
gDeriv2=uicontrol(...
'Style','Text',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[10 20 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Center',...
'FontSize',8);
%%%%%%%%%%%%%%% g(x) Integrals %%%%%%%%%%%%%%%
%g(x) Integral Panel
gIntPanel=uipanel(...
'Parent',gPanel,...
'Units','Pixels',...
'Position',[10 10 220 280],...
'BackgroundColor',gPanColor);
%g(x) Text: Definite Integral of g(x)
gIntTitleText=uicontrol(...
'Style','Text',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[10 240 200 30],...
'BackgroundColor',gPanColor,...
'String','Definite Integral of g(x)',...
'HorizontalAlignment','Center',...
'FontSize',12);
%g(x) Text: Lower Bound
gIntLowText=uicontrol(...
'Style','Text',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[10 190 80 30],...
'BackgroundColor',gPanColor,...
'String','Lower Bound:',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g(x) Edit Lower Bound
gIntLowEdit=uicontrol(...
'Style','Edit',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[90 200 120 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g(x) Text: Upper Bound
gIntUpText=uicontrol(...
'Style','Text',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[10 140 80 30],...
'BackgroundColor',gPanColor,...
'String','Upper Bound:',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g(x) Edit Upper Bound
gIntUpEdit=uicontrol(...
'Style','Edit',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[90 150 120 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g(x) Text: Area=
gIntAreaText=uicontrol(...
'Style','Text',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[10 90 200 40],...
'BackgroundColor',gPanColor,...
'String','Area Under g(x) from the Lower to Upper Bound=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g(x) Area Text
gIntArea=uicontrol(...
'Style','Text',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[10 60 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Center',...
'FontSize',8);
%g(x) Area Radio Button
gShowAreaRadio=uicontrol(...
'Style','Radio',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[10 20 20 20],...
'BackgroundColor',gPanColor,...
'Callback',@gIntRadio_Callback);
%g(x) Area Push Button
gShowAreaPush=uicontrol(...
'Style','Push',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[30 15 180 30],...
'BackgroundColor',gPanColor,...
'String','Calculate Area',...
'Callback',@gIntShowArea_Callback);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%% Normalize All Handles %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles=[InstructFigure,InstructText0,InstructText1,InstructText2,...
InstructText3,InstructText4,InstructText5,InstructText6,...
InstructText7,InstructText8,hFigure,hAxes,hTitle,xyPanel,...
xMinText,xMinEdit,xMaxText,xMaxEdit,yMinText,yMinEdit,yMaxText,...
yMaxEdit,fPanel,fFcnPanel,fFcnTitleText,fFcnText,fFcnRadio,fFcn,...
fDerivPanel,fDerivTitleText,fDerivText,fDerivRadio,fDeriv,...
fDeriv2Text,fDeriv2Radio,fDeriv2,fIntPanel,fIntTitleText,...
fIntLowText,fIntLowEdit,fIntUpText,fIntUpEdit,fIntAreaText,fIntArea,...
fShowAreaRadio,fShowAreaPush,gPanel,gFcnPanel,gFcnTitleText,...
gFcnText,gFcnRadio,gFcn,gDerivPanel,gDerivTitleText,gDerivText,...
gDerivRadio,gDeriv,gDeriv2Text,gDeriv2Radio,gDeriv2,gIntPanel,...
gIntTitleText,gIntLowText,gIntLowEdit,gIntUpText,gIntUpEdit,...
gIntAreaText,gIntArea,gShowAreaRadio,gShowAreaPush];
set(handles,...
'Units','Normalized');
%%%%%%%%%%%%%%%%%%%%%%%%%%%% xyLims Callbacks %%%%%%%%%%%%%%%%%%%%%%%%%%%%
% xy xMin Callback
function xMin_Callback(hObject,eventdata)
x=get(hAxes,'XLim');
xmin=str2double(get(hObject,'String'));
set(hAxes,'XLim',[xmin x(2)])
end %ends xMin_Callback
% xy xMax Callback
function xMax_Callback(hObject,eventdata)
x=get(hAxes,'XLim');
xmax=str2double(get(hObject,'String'));
set(hAxes,'XLim',[x(1) xmax])
end %ends xMax_Callback
% xy yMin Callback
function yMin_Callback(hObject,eventdata)
y=get(hAxes,'YLim');
ymin=str2double(get(hObject,'String'));
set(hAxes,'YLim',[ymin y(2)])
end %ends yMin_Callback
% xy yMax Callback
function yMax_Callback(hObject,eventdata)
y=get(hAxes,'YLim');
ymax=str2double(get(hObject,'String'));
set(hAxes,'YLim',[y(1) ymax])
end %ends yMax_Callback
% % f(x) Primary Function Callback
% function fFcn_Callback(hObject,eventdata)
% end %ends fFcn_Callback
%
% f(x) Primary Function Show Graph Callback
function fFcnShg_Callback(hObject,eventdata)
f=fcnchk(get(fFcn,'String'),'vectorized');
x=get(hAxes,'XLim');
xx=linspace(x(1),x(2),numpts);
y=feval(f,xx);
fswitch=get(hObject,'Value');
switch fswitch
case 0
set(fLine,...
'LineStyle','none');
case 1
set(fLine,...
'XData',xx,...
'YData',y,...
'LineStyle','-');
end
end %ends fFcnShg_Callback
% f`(x) Function Show Graph Callback
function fDerivShg_Callback(hObject,eventdata)
x=get(hAxes,'XLim');
xx=linspace(x(1),x(2),numpts);
f=get(fFcn,'String');
ff=char(diff(f));
set(fDeriv,'String',ff);
y=fcnchk(get(fDeriv,'String'),'vectorized');
yy=feval(y,xx);
ffswitch=get(hObject,'Value');
switch ffswitch
case 0
set(ffLine,...
'LineStyle','none');
case 1
set(ffLine,...
'XData',xx,...
'YData',yy,...
'LineStyle','--');
end
end %ends fDerivShg_Callback
% f``(x) Function Show Graph Callback
function fDeriv2Shg_Callback(hObject,eventdata)
fffswitch=get(hObject,'Value');
x=get(hAxes,'XLim');
xx=linspace(x(1),x(2),numpts);
ff=get(fDeriv,'String');
fff=char(diff(ff));
set(fDeriv2,'String',fff);
y=fcnchk(get(fDeriv2,'String'),'vectorized');
yy=feval(y,xx);
switch fffswitch
case 0
set(fffLine,'LineStyle','none');
case 1
set(fffLine,...
'XData',xx,...
'YData',yy,...
'LineStyle',':');
end
end %ends fDeriv2Shg_Callback
% f(x) Integral Show Area on Graph Callback
function fIntRadio_Callback(hObject,eventdata)
a=str2double(get(fIntLowEdit,'String'));
b=str2double(get(fIntUpEdit,'String'));
fareafswitch=get(hObject,'Value');
switch fareafswitch
case 0
set(areaf,...
'XData',[],...
'YData',0,...
'FaceColor','none');
case 1
x=get(fLine,'XData');
y=get(fLine,'YData');
k=((a<=x) & (x<=b));
yy=y(k);
numberpoints=size(yy);
xx=linspace(a,b,numberpoints(2));
set(areaf,...
'XData',xx,...
'YData',yy,...
'FaceColor',fPanColor);
xmin=str2double(get(xMinEdit,'String'));
xmax=str2double(get(xMaxEdit,'String'));
ymin=str2double(get(yMinEdit,'String'));
ymax=str2double(get(yMaxEdit,'String'));
set(hAxes,...
'XLim',[xmin xmax],...
'YLim',[ymin ymax]);
end
end %ends fIntRadio_Callback
% f(x) Integral Calculate Area Callback
function fIntShowArea_Callback(hObject,eventdata)
f=get(fFcn,'String');
a=str2double(get(fIntLowEdit,'String'));
b=str2double(get(fIntUpEdit,'String'));
farea=double(int(f,a,b));
set(fIntArea,'String',farea);
end %ends fIntShowArea_Callback
% g(x) Primary Function Callback
function gFcn_Callback(hObject,eventdata)
end %ends gFcn_Callback
% g(x) Primary Function Show Graph Callback
function gFcnShg_Callback(hObject,eventdata)
g=fcnchk(get(gFcn,'String'),'vectorized');
x=get(hAxes,'XLim');
xx=linspace(x(1),x(2),numpts);
y=feval(g,xx);
gswitch=get(hObject,'Value');
switch gswitch
case 0
set(gLine,'LineStyle','none');
case 1
set(gLine,...
'XData',xx,...
'YData',y,...
'LineStyle','-');
end
end %ends gFcnShg_Callback
% g`(x) Function Show Graph Callback
function gDerivShg_Callback(hObject,eventdata)
x=get(hAxes,'XLim');
xx=linspace(x(1),x(2),numpts);
g=get(gFcn,'String');
gg=char(diff(g));
set(gDeriv,'String',gg);
y=fcnchk(get(gDeriv,'String'),'vectorized');
yy=feval(y,xx);
ggswitch=get(hObject,'Value');
switch ggswitch
case 0
set(ggLine,...
'LineStyle','none');
case 1
set(ggLine,...
'XData',xx,...
'YData',yy,...
'LineStyle','--');
end
end %ends gDerivShg_Callback
% g``(x) Function Show Graph Callback
function gDeriv2Shg_Callback(hObject,eventdata)
gggswitch=get(hObject,'Value');
x=get(hAxes,'XLim');
xx=linspace(x(1),x(2),numpts);
gg=get(gDeriv,'String');
ggg=char(diff(gg));
set(gDeriv2,'String',ggg);
y=fcnchk(get(gDeriv2,'String'),'vectorized');
yy=feval(y,xx);
switch gggswitch
case 0
set(gggLine,...
'LineStyle','none');
case 1
set(gggLine,...
'XData',xx,...
'YData',yy,...
'LineStyle',':');
end
end %ends gDeriv2Shg_Callback
function gIntRadio_Callback(hObject,eventdata)
a=str2double(get(gIntLowEdit,'String'));
b=str2double(get(gIntUpEdit,'String'));
gareagswitch=get(hObject,'Value');
switch gareagswitch
case 0
set(areag,...
'XData',[],...
'YData',0,...
'FaceColor','none');
case 1
x=get(gLine,'XData');
y=get(gLine,'YData');
k=((a<=x) & (x<=b));
yy=y(k);
numberpoints=size(yy);
xx=linspace(a,b,numberpoints(2));
set(areag,...
'XData',xx,...
'YData',yy,...
'FaceColor',gPanColor);
xmin=str2double(get(xMinEdit,'String'));
xmax=str2double(get(xMaxEdit,'String'));
ymin=str2double(get(yMinEdit,'String'));
ymax=str2double(get(yMaxEdit,'String'));
set(hAxes,...
'XLim',[xmin xmax],...
'YLim',[ymin ymax]);
end
end %ends gIntRadio_Callback
% g(x) Integral Show Area on Graph Callback
function gIntShowArea_Callback(hObject,eventdata)
g=get(gFcn,'String');
a=str2double(get(gIntLowEdit,'String'));
b=str2double(get(gIntUpEdit,'String'));
garea=double(int(g,a,b));
set(gIntArea,'String',garea);
end %ends gIntShowArea_Callback
end
%Function CALCGUI. Integral and Derivative Functions GUI.
% CALCGUI shows the first and second derivatives of the primary functions
% f(x) and g(x) as well as the area from the lower to upper bounds of the
% primary functions. It also displays the equations of the first and
% second derivatives and the area displayed.
close all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Constant Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hFigColor=[0.6 0.6 0.6];
xyPanColor=[0 0.7 0];
fPanColor=[0.2 0.4 1];
gPanColor=[1 0.2 0.1];
EditColor=[0.95 0.95 0.95];
InstructColor=[0.75 0.75 0.75];
numpts=500;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%% Instructions Window %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
InstructFigure=figure(...
'Units','Pixels',...
'Position',[0 38 300 850],...
'MenuBar','None',...
'NumberTitle','off',...
'Color',InstructColor,...
'Name','Instruction for Calculator');
Instructions0='Instructions for Calculator';
Instructions1='Calculator is used to calculate the Symbolic first and second derivatives of two single-variable functions. Calculator also graphs the primary functions, its first and second derivatives, and the definite integral (area under the curve from the lower to upper bounds) on the given axes. CalcGUI allows for two simultaneous equations to be acted upon.';
Instructions2='Using the Primary Function panels.';
Instructions3='Enter the primary equation into the Edit Rectangle (nearly-white). After doing so, you may show the graph of the entered function on the axes by pushing the Radio Button above and to the left of your equation. ***Note: The equation MUST be a single-variable equation.';
Instructions4='Using the 1st and 2nd Derivatives panels.';
Instructions5='After entering an equation into the Primary Function panel above, you can calculate and show the first and second derivatives of the primary function. Pushing the Radio button next to f`(x) will display the first derivative of the primary function and graph it. Pushing the Radio button next to f``(x) will calculate and graph the second derivative of the primary function. Pressing either Radio button again will recalculate the derivative and remove the graph. ';
Instructions6='Using the Definite Integral panels.';
Instructions7='After entering an equation into the Primary Function panel above, you can calculate and show the definite integral of the primary function. First, enter both Lower and Upper Bounds to integrate. When you push the ''Calculate Area'' button, the definite integral of the primary function from the Lower Bound to the Upper Bound will be displayed in the rectangle above the button. Pressing the Radio button will display the area under the curve between the lower and upper bounds, representing the area attained.';
InstructText0=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 825 290 25],...
'String',Instructions0,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor,...
'FontWeight','Bold',...
'FontSize',14);
InstructText1=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 680 290 135],...
'String',Instructions1,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor);
InstructText2=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 650 290 20],...
'String',Instructions2,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor,...
'FontWeight','Bold');
InstructText3=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 523 290 125],...
'String',Instructions3,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor);
InstructText4=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 493 290 20],...
'String',Instructions4,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor,...
'FontWeight','Bold');
InstructText5=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 303 290 190],...
'String',Instructions5,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor);
InstructText6=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 274 290 20],...
'String',Instructions6,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor,...
'FontWeight','Bold');
InstructText7=uicontrol(...
'Style','Text',...
'Parent',InstructFigure,...
'Units','Pixels',...
'Position',[5 75 290 200],...
'String',Instructions7,...
'HorizontalAlignment','Left',...
'BackgroundColor',InstructColor);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Main Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Primary Figure Window
hFigure=figure(...
'Units','Pixels',...
'Position',[308 38 1200 800],...
'Color',hFigColor,...
'MenuBar','None',...
'NumberTitle','off',...
'Name','CalcGUI');
%Axes
hAxes=axes(...
'Parent',hFigure,...
'Units','Pixels',...
'Position',[300 150 600 600],...
'XGrid','on',...
'YGrid','on',...
'XLim',[-10 10],...
'YLim',[-10,10]);
%Title
hTitle=uicontrol(...
'Style','Text',...
'Units','Pixels',...
'Parent',hFigure,...
'Position',[300 750 600 30],...
'BackgroundColor',hFigColor,...
'String','Single Variable Calculus Calculator with 2 Functions',...
'FontSize',16,...
'HorizontalAlignment','Center');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Image Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This creates the 'background' axes
ImAxes=axes(...
'Parent',hFigure,...
'Units','Normalized',...
'Position',[0 0 1 1]);
% Move the background axes to the bottom
uistack(ImAxes,'bottom');
% Load in a background image and display it using the correct colors
% The image used below, is in the Image Processing Toolbox. If you do not have %access to this toolbox, you can use another image file instead.
I=imread('ConTrail.png');
Im=imagesc(I);
colormap gray
% Turn the handlevisibility off so that we don't inadvertently plot into the axes again
% Also, make the axes invisible
set(ImAxes,...
'handlevisibility','off', ...
'visible','off');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Line Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Line Setup
fLine=line();
set(fLine,...
'XData',[],...
'YData',[],...
'LineStyle','none',...
'LineWidth',2,...
'Color','b');
ffLine=line();
set(ffLine,...
'XData',[],...
'YData',[],...
'LineStyle','none',...
'LineWidth',2,...
'Color','b');
fffLine=line();
set(fffLine,...
'XData',[],...
'YData',[],...
'LineStyle','none',...
'LineWidth',2,...
'Color','b');
gLine=line();
set(gLine,...
'XData',[],...
'YData',[],...
'LineStyle','none',...
'LineWidth',2,...
'Color','r');
ggLine=line();
set(ggLine,...
'XData',[],...
'YData',[],...
'LineStyle','none',...
'LineWidth',2,...
'Color','r');
gggLine=line();
set(gggLine,...
'XData',[],...
'YData',[],...
'LineStyle','none',...
'LineWidth',2,...
'Color','r');
xaxis=line([-1000000,1000000],[0,0],...
'Color','k',...
'LineWidth',1.3);
yaxis=line([0,0],[-1000000,1000000],...
'Color','k',...
'LineWidth',1.3);
hold on
areaf=area(0);
set(areaf,'YData',0,...
'EdgeColor','none',...
'FaceColor','none');
areag=area(0);
set(areag,'YData',0,...
'EdgeColor','none',...
'FaceColor','none');
hold off
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% xyLims Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%X and Y Limits Panel
xyPanel=uipanel(...
'Parent',hFigure,...
'Units','Pixels',...
'Position',[300 20 600 100],...
'BackgroundColor',xyPanColor);
%xy xMin Text: X Min
xMinText=uicontrol(...
'Style','Text',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[10 60 60 25],...
'BackgroundColor',xyPanColor,...
'String','X Min: ',...
'HorizontalAlignment','Left',...
'FontSize',12);
%xy xMin Edit
xMinEdit=uicontrol(...
'Style','Edit',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[80 60 200 25],...
'String','-10',...
'HorizontalAlignment','Left',...
'FontSize',8,...
'Callback',@xMin_Callback);
%xy xMax Text: X Max
xMaxText=uicontrol(...
'Style','Text',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[10 15 60 25],...
'BackgroundColor',xyPanColor,...
'String','X Max: ',...
'HorizontalAlignment','Left',...
'FontSize',12);
%xy xMax Edit
xMaxEdit=uicontrol(...
'Style','Edit',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[80 15 200 25],...
'String','10',...
'HorizontalAlignment','Left',...
'FontSize',8,...
'Callback',@xMax_Callback);
%xy yMin Text: Y Min
yMinText=uicontrol(...
'Style','Text',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[310 60 60 25],...
'BackgroundColor',xyPanColor,...
'String','Y Min: ',...
'HorizontalAlignment','Left',...
'FontSize',12);
%xy yMin Edit
yMinEdit=uicontrol(...
'Style','Edit',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[380 60 200 25],...
'String','-10',...
'HorizontalAlignment','Left',...
'FontSize',8,...
'Callback',@yMin_Callback);
%xy yMax Text: Y Max
yMaxText=uicontrol(...
'Style','Text',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[310 15 60 25],...
'BackgroundColor',xyPanColor,...
'String','Y Max: ',...
'HorizontalAlignment','Left',...
'FontSize',12);
%xy yMax Edit
yMaxEdit=uicontrol(...
'Style','Edit',...
'Parent',xyPanel,...
'Units','Pixels',...
'Position',[380 15 200 25],...
'String','10',...
'HorizontalAlignment','Left',...
'FontSize',8,...
'Callback',@yMax_Callback);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% f(x) Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%fPanel
fPanel=uipanel(...
'Parent',hFigure,...
'Units','Pixels',...
'Position',[30 150 240 600],...
'BackgroundColor',fPanColor);
%%%%%%%%%%%%%%% f(x) Primary Function %%%%%%%%%%%%%%%
%f(x) Primary Function Panel
fFcnPanel=uipanel(...
'Parent',fPanel,...
'Units','Pixels',...
'Position',[10 490 220 100],...
'BackgroundColor',fPanColor);
%f(x) Text: Primary Function f(x)
fFcnTitleText=uicontrol(...
'Style','Text',...
'Parent',fFcnPanel,...
'Units','Pixels',...
'Position',[10 60 200 30],...
'BackgroundColor',fPanColor,...
'String','Primary Function f(x)',...
'HorizontalAlignment','Center',...
'FontSize',12);
%f(x) Text f(x)=
fFcnText=uicontrol(...
'Style','Text',...
'Parent',fFcnPanel,...
'Units','Pixels',...
'Position',[33 33 30 30],...
'BackgroundColor',fPanColor,...
'String','f(x)=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f(x) Radio Button
fFcnRadio=uicontrol(...
'Style','Radio',...
'Parent',fFcnPanel,...
'Units','Pixels',...
'Position',[10 45 20 20],...
'BackgroundColor',fPanColor,...
'Callback',@fFcnShg_Callback);
%f(x) Edit f(x)
fFcn=uicontrol(...
'Style','Edit',...
'Parent',fFcnPanel,...
'Units','Pixels',...
'Position',[10 10 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Left',...
'FontSize',8);
%%%%%%%%%%%%%%% f(x) Derivatives %%%%%%%%%%%%%%%
%f(x) Derivative Panel
fDerivPanel=uipanel(...
'Parent',fPanel,...
'Units','Pixels',...
'Position',[10 300 220 180],...
'BackgroundColor',fPanColor);
%f(x) Text: 1st and 2nd Derivatives
fDerivTitleText=uicontrol(...
'Style','Text',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[10 140 200 30],...
'BackgroundColor',fPanColor,...
'String','1st and 2nd Derivatives',...
'HorizontalAlignment','Center',...
'FontSize',12);
%f`(x) Text f`(x)=
fDerivText=uicontrol(...
'Style','Text',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[33 118 45 20],...
'BackgroundColor',fPanColor,...
'String','f`(x)=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f`(x) Radio Button
fDerivRadio=uicontrol(...
'Style','Radio',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[10 120 20 20],...
'BackgroundColor',fPanColor,...
'Callback',@fDerivShg_Callback);
%f`(x) f`(x) Text
fDeriv=uicontrol(...
'Style','Text',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[10 85 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Center',...
'FontSize',8,...
'Callback',@fDeriv_Callback);
%f``(x) Text f``(x)=
fDeriv2Text=uicontrol(...
'Style','Text',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[33 53 45 20],...
'BackgroundColor',fPanColor,...
'String','f``(x)=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f``(x) Radio Button
fDeriv2Radio=uicontrol(...
'Style','Radio',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[10 55 20 20],...
'BackgroundColor',fPanColor,...
'Callback',@fDeriv2Shg_Callback);
%f``(x) f``(x) Text
fDeriv2=uicontrol(...
'Style','Text',...
'Parent',fDerivPanel,...
'Units','Pixels',...
'Position',[10 20 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Center',...
'FontSize',8,...
'Callback',@fDeriv2_Callback);
%%%%%%%%%%%%%%% f(x) Integrals %%%%%%%%%%%%%%%
%f(x) Integral Panel
fIntPanel=uipanel(...
'Parent',fPanel,...
'Units','Pixels',...
'Position',[10 10 220 280],...
'BackgroundColor',fPanColor);
%f(x) Text: Definite Integral of f(x)
fIntTitleText=uicontrol(...
'Style','Text',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[10 240 200 30],...
'BackgroundColor',fPanColor,...
'String','Definite Integral of f(x)',...
'HorizontalAlignment','Center',...
'FontSize',12);
%f(x) Text: Lower Bound
fIntLowText=uicontrol(...
'Style','Text',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[10 190 80 30],...
'BackgroundColor',fPanColor,...
'String','Lower Bound:',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f(x) Edit Lower Bound
fIntLowEdit=uicontrol(...
'Style','Edit',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[90 200 120 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f(x) Text: Upper Bound
fIntUpText=uicontrol(...
'Style','Text',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[10 140 80 30],...
'BackgroundColor',fPanColor,...
'String','Upper Bound:',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f(x) Edit Upper Bound
fIntUpEdit=uicontrol(...
'Style','Edit',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[90 150 120 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f(x) Text: Area=
fIntAreaText=uicontrol(...
'Style','Text',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[10 90 200 40],...
'BackgroundColor',fPanColor,...
'String','Area Under f(x) from the Lower to Upper Bound=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%f(x) Area Text
fIntArea=uicontrol(...
'Style','Text',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[10 60 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Center',...
'FontSize',8);
%f(x) Area Radio Button
fShowAreaRadio=uicontrol(...
'Style','Radio',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[10 20 20 20],...
'BackgroundColor',fPanColor,...
'Callback',@fIntRadio_Callback);
%f(x) Area Push Button
fShowAreaPush=uicontrol(...
'Style','Push',...
'Parent',fIntPanel,...
'Units','Pixels',...
'Position',[30 15 180 30],...
'BackgroundColor',fPanColor,...
'String','Calculate Area',...
'Callback',@fIntShowArea_Callback);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% g(x) Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%gPanel
gPanel=uipanel(...
'Parent',hFigure,...
'Units','Pixels',...
'Position',[930 150 240 600],...
'BackgroundColor',gPanColor);
%%%%%%%%%%%%%%% g(x) Primary Function %%%%%%%%%%%%%%%
%g(x) Primary Function Panel
gFcnPanel=uipanel(...
'Parent',gPanel,...
'Units','Pixels',...
'Position',[10 490 220 100],...
'BackgroundColor',gPanColor);
%g(x) Text: Primary Function g(x)
gFcnTitleText=uicontrol(...
'Style','Text',...
'Parent',gFcnPanel,...
'Units','Pixels',...
'Position',[10 60 200 30],...
'BackgroundColor',gPanColor,...
'String','Primary Function g(x)',...
'HorizontalAlignment','Center',...
'FontSize',12);
%g(x) Text g(x)=
gFcnText=uicontrol(...
'Style','Text',...
'Parent',gFcnPanel,...
'Units','Pixels',...
'Position',[33 33 30 30],...
'BackgroundColor',gPanColor,...
'String','g(x)=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g(x) Radio Button
gFcnRadio=uicontrol(...
'Style','Radio',...
'Parent',gFcnPanel,...
'Units','Pixels',...
'Position',[10 45 20 20],...
'BackgroundColor',gPanColor,...
'Callback',@gFcnShg_Callback);
%g(x) Edit g(x)
gFcn=uicontrol(...
'Style','Edit',...
'Parent',gFcnPanel,...
'Units','Pixels',...
'Position',[10 10 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Left',...
'FontSize',8);
%%%%%%%%%%%%%%% g(x) Derivatives %%%%%%%%%%%%%%%
%g(x) Derivative Panel
gDerivPanel=uipanel(...
'Parent',gPanel,...
'Units','Pixels',...
'Position',[10 300 220 180],...
'BackgroundColor',gPanColor);
%g(x) Text: 1st and 2nd Derivatives
gDerivTitleText=uicontrol(...
'Style','Text',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[10 140 200 30],...
'BackgroundColor',gPanColor,...
'String','1st and 2nd Derivatives',...
'HorizontalAlignment','Center',...
'FontSize',12);
%g`(x) Text g`(x)=
gDerivText=uicontrol(...
'Style','Text',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[33 118 45 20],...
'BackgroundColor',gPanColor,...
'String','g`(x)=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g`(x) Radio Button
gDerivRadio=uicontrol(...
'Style','Radio',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[10 120 20 20],...
'BackgroundColor',gPanColor,...
'Callback',@gDerivShg_Callback);
%g`(x) g`(x) Text
gDeriv=uicontrol(...
'Style','Text',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[10 85 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Center',...
'FontSize',8);
%g``(x) Text g``(x)=
gDeriv2Text=uicontrol(...
'Style','Text',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[33 53 45 20],...
'BackgroundColor',gPanColor,...
'String','g``(x)=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g``(x) Radio Button
gDeriv2Radio=uicontrol(...
'Style','Radio',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[10 55 20 20],...
'BackgroundColor',gPanColor,...
'Callback',@gDeriv2Shg_Callback);
%g``(x) g``(x) Text
gDeriv2=uicontrol(...
'Style','Text',...
'Parent',gDerivPanel,...
'Units','Pixels',...
'Position',[10 20 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Center',...
'FontSize',8);
%%%%%%%%%%%%%%% g(x) Integrals %%%%%%%%%%%%%%%
%g(x) Integral Panel
gIntPanel=uipanel(...
'Parent',gPanel,...
'Units','Pixels',...
'Position',[10 10 220 280],...
'BackgroundColor',gPanColor);
%g(x) Text: Definite Integral of g(x)
gIntTitleText=uicontrol(...
'Style','Text',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[10 240 200 30],...
'BackgroundColor',gPanColor,...
'String','Definite Integral of g(x)',...
'HorizontalAlignment','Center',...
'FontSize',12);
%g(x) Text: Lower Bound
gIntLowText=uicontrol(...
'Style','Text',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[10 190 80 30],...
'BackgroundColor',gPanColor,...
'String','Lower Bound:',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g(x) Edit Lower Bound
gIntLowEdit=uicontrol(...
'Style','Edit',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[90 200 120 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g(x) Text: Upper Bound
gIntUpText=uicontrol(...
'Style','Text',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[10 140 80 30],...
'BackgroundColor',gPanColor,...
'String','Upper Bound:',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g(x) Edit Upper Bound
gIntUpEdit=uicontrol(...
'Style','Edit',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[90 150 120 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g(x) Text: Area=
gIntAreaText=uicontrol(...
'Style','Text',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[10 90 200 40],...
'BackgroundColor',gPanColor,...
'String','Area Under g(x) from the Lower to Upper Bound=',...
'HorizontalAlignment','Left',...
'FontSize',8);
%g(x) Area Text
gIntArea=uicontrol(...
'Style','Text',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[10 60 200 25],...
'BackgroundColor',EditColor,...
'String','',...
'HorizontalAlignment','Center',...
'FontSize',8);
%g(x) Area Radio Button
gShowAreaRadio=uicontrol(...
'Style','Radio',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[10 20 20 20],...
'BackgroundColor',gPanColor,...
'Callback',@gIntRadio_Callback);
%g(x) Area Push Button
gShowAreaPush=uicontrol(...
'Style','Push',...
'Parent',gIntPanel,...
'Units','Pixels',...
'Position',[30 15 180 30],...
'BackgroundColor',gPanColor,...
'String','Calculate Area',...
'Callback',@gIntShowArea_Callback);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%% Normalize All Handles %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles=[InstructFigure,InstructText0,InstructText1,InstructText2,...
InstructText3,InstructText4,InstructText5,InstructText6,...
InstructText7,InstructText8,hFigure,hAxes,hTitle,xyPanel,...
xMinText,xMinEdit,xMaxText,xMaxEdit,yMinText,yMinEdit,yMaxText,...
yMaxEdit,fPanel,fFcnPanel,fFcnTitleText,fFcnText,fFcnRadio,fFcn,...
fDerivPanel,fDerivTitleText,fDerivText,fDerivRadio,fDeriv,...
fDeriv2Text,fDeriv2Radio,fDeriv2,fIntPanel,fIntTitleText,...
fIntLowText,fIntLowEdit,fIntUpText,fIntUpEdit,fIntAreaText,fIntArea,...
fShowAreaRadio,fShowAreaPush,gPanel,gFcnPanel,gFcnTitleText,...
gFcnText,gFcnRadio,gFcn,gDerivPanel,gDerivTitleText,gDerivText,...
gDerivRadio,gDeriv,gDeriv2Text,gDeriv2Radio,gDeriv2,gIntPanel,...
gIntTitleText,gIntLowText,gIntLowEdit,gIntUpText,gIntUpEdit,...
gIntAreaText,gIntArea,gShowAreaRadio,gShowAreaPush];
set(handles,...
'Units','Normalized');
%%%%%%%%%%%%%%%%%%%%%%%%%%%% xyLims Callbacks %%%%%%%%%%%%%%%%%%%%%%%%%%%%
% xy xMin Callback
function xMin_Callback(hObject,eventdata)
x=get(hAxes,'XLim');
xmin=str2double(get(hObject,'String'));
set(hAxes,'XLim',[xmin x(2)])
end %ends xMin_Callback
% xy xMax Callback
function xMax_Callback(hObject,eventdata)
x=get(hAxes,'XLim');
xmax=str2double(get(hObject,'String'));
set(hAxes,'XLim',[x(1) xmax])
end %ends xMax_Callback
% xy yMin Callback
function yMin_Callback(hObject,eventdata)
y=get(hAxes,'YLim');
ymin=str2double(get(hObject,'String'));
set(hAxes,'YLim',[ymin y(2)])
end %ends yMin_Callback
% xy yMax Callback
function yMax_Callback(hObject,eventdata)
y=get(hAxes,'YLim');
ymax=str2double(get(hObject,'String'));
set(hAxes,'YLim',[y(1) ymax])
end %ends yMax_Callback
% % f(x) Primary Function Callback
% function fFcn_Callback(hObject,eventdata)
% end %ends fFcn_Callback
%
% f(x) Primary Function Show Graph Callback
function fFcnShg_Callback(hObject,eventdata)
f=fcnchk(get(fFcn,'String'),'vectorized');
x=get(hAxes,'XLim');
xx=linspace(x(1),x(2),numpts);
y=feval(f,xx);
fswitch=get(hObject,'Value');
switch fswitch
case 0
set(fLine,...
'LineStyle','none');
case 1
set(fLine,...
'XData',xx,...
'YData',y,...
'LineStyle','-');
end
end %ends fFcnShg_Callback
% f`(x) Function Show Graph Callback
function fDerivShg_Callback(hObject,eventdata)
x=get(hAxes,'XLim');
xx=linspace(x(1),x(2),numpts);
f=get(fFcn,'String');
ff=char(diff(f));
set(fDeriv,'String',ff);
y=fcnchk(get(fDeriv,'String'),'vectorized');
yy=feval(y,xx);
ffswitch=get(hObject,'Value');
switch ffswitch
case 0
set(ffLine,...
'LineStyle','none');
case 1
set(ffLine,...
'XData',xx,...
'YData',yy,...
'LineStyle','--');
end
end %ends fDerivShg_Callback
% f``(x) Function Show Graph Callback
function fDeriv2Shg_Callback(hObject,eventdata)
fffswitch=get(hObject,'Value');
x=get(hAxes,'XLim');
xx=linspace(x(1),x(2),numpts);
ff=get(fDeriv,'String');
fff=char(diff(ff));
set(fDeriv2,'String',fff);
y=fcnchk(get(fDeriv2,'String'),'vectorized');
yy=feval(y,xx);
switch fffswitch
case 0
set(fffLine,'LineStyle','none');
case 1
set(fffLine,...
'XData',xx,...
'YData',yy,...
'LineStyle',':');
end
end %ends fDeriv2Shg_Callback
% f(x) Integral Show Area on Graph Callback
function fIntRadio_Callback(hObject,eventdata)
a=str2double(get(fIntLowEdit,'String'));
b=str2double(get(fIntUpEdit,'String'));
fareafswitch=get(hObject,'Value');
switch fareafswitch
case 0
set(areaf,...
'XData',[],...
'YData',0,...
'FaceColor','none');
case 1
x=get(fLine,'XData');
y=get(fLine,'YData');
k=((a<=x) & (x<=b));
yy=y(k);
numberpoints=size(yy);
xx=linspace(a,b,numberpoints(2));
set(areaf,...
'XData',xx,...
'YData',yy,...
'FaceColor',fPanColor);
xmin=str2double(get(xMinEdit,'String'));
xmax=str2double(get(xMaxEdit,'String'));
ymin=str2double(get(yMinEdit,'String'));
ymax=str2double(get(yMaxEdit,'String'));
set(hAxes,...
'XLim',[xmin xmax],...
'YLim',[ymin ymax]);
end
end %ends fIntRadio_Callback
% f(x) Integral Calculate Area Callback
function fIntShowArea_Callback(hObject,eventdata)
f=get(fFcn,'String');
a=str2double(get(fIntLowEdit,'String'));
b=str2double(get(fIntUpEdit,'String'));
farea=double(int(f,a,b));
set(fIntArea,'String',farea);
end %ends fIntShowArea_Callback
% g(x) Primary Function Callback
function gFcn_Callback(hObject,eventdata)
end %ends gFcn_Callback
% g(x) Primary Function Show Graph Callback
function gFcnShg_Callback(hObject,eventdata)
g=fcnchk(get(gFcn,'String'),'vectorized');
x=get(hAxes,'XLim');
xx=linspace(x(1),x(2),numpts);
y=feval(g,xx);
gswitch=get(hObject,'Value');
switch gswitch
case 0
set(gLine,'LineStyle','none');
case 1
set(gLine,...
'XData',xx,...
'YData',y,...
'LineStyle','-');
end
end %ends gFcnShg_Callback
% g`(x) Function Show Graph Callback
function gDerivShg_Callback(hObject,eventdata)
x=get(hAxes,'XLim');
xx=linspace(x(1),x(2),numpts);
g=get(gFcn,'String');
gg=char(diff(g));
set(gDeriv,'String',gg);
y=fcnchk(get(gDeriv,'String'),'vectorized');
yy=feval(y,xx);
ggswitch=get(hObject,'Value');
switch ggswitch
case 0
set(ggLine,...
'LineStyle','none');
case 1
set(ggLine,...
'XData',xx,...
'YData',yy,...
'LineStyle','--');
end
end %ends gDerivShg_Callback
% g``(x) Function Show Graph Callback
function gDeriv2Shg_Callback(hObject,eventdata)
gggswitch=get(hObject,'Value');
x=get(hAxes,'XLim');
xx=linspace(x(1),x(2),numpts);
gg=get(gDeriv,'String');
ggg=char(diff(gg));
set(gDeriv2,'String',ggg);
y=fcnchk(get(gDeriv2,'String'),'vectorized');
yy=feval(y,xx);
switch gggswitch
case 0
set(gggLine,...
'LineStyle','none');
case 1
set(gggLine,...
'XData',xx,...
'YData',yy,...
'LineStyle',':');
end
end %ends gDeriv2Shg_Callback
function gIntRadio_Callback(hObject,eventdata)
a=str2double(get(gIntLowEdit,'String'));
b=str2double(get(gIntUpEdit,'String'));
gareagswitch=get(hObject,'Value');
switch gareagswitch
case 0
set(areag,...
'XData',[],...
'YData',0,...
'FaceColor','none');
case 1
x=get(gLine,'XData');
y=get(gLine,'YData');
k=((a<=x) & (x<=b));
yy=y(k);
numberpoints=size(yy);
xx=linspace(a,b,numberpoints(2));
set(areag,...
'XData',xx,...
'YData',yy,...
'FaceColor',gPanColor);
xmin=str2double(get(xMinEdit,'String'));
xmax=str2double(get(xMaxEdit,'String'));
ymin=str2double(get(yMinEdit,'String'));
ymax=str2double(get(yMaxEdit,'String'));
set(hAxes,...
'XLim',[xmin xmax],...
'YLim',[ymin ymax]);
end
end %ends gIntRadio_Callback
% g(x) Integral Show Area on Graph Callback
function gIntShowArea_Callback(hObject,eventdata)
g=get(gFcn,'String');
a=str2double(get(gIntLowEdit,'String'));
b=str2double(get(gIntUpEdit,'String'));
garea=double(int(g,a,b));
set(gIntArea,'String',garea);
end %ends gIntShowArea_Callback
end
No comments:
Post a Comment