Equation Animator Using Matlab

13
THDC Institute of Hydropower Engineering and Technology Tehri Gharwal, Uttarakhand India Project Report on “Equ tion nim tor  usin m tl b”   by Charu Kandpal  Ankur Sharma Md. Gufran Hashmi Rahul Singh Kharayat (Electrical Engineering 3 rd  Year) Under Guidance of Mr. Vivek Kumar Assistant Professor Department Of Computer Science THDC Institute of Hydropower Engineering and Technology Tehri Gharwal, Uttarakhand India

description

Matlab callback function and detailed report to make an equation animation of a binomial equation.

Transcript of Equation Animator Using Matlab

THDC Institute of Hydropower Engineering and Technology Tehri Gharwal, UttarakhandIndia

Project Report on

Equation Animator using Matlab

by

Charu Kandpal Ankur Sharma Md. Gufran HashmiRahul Singh Kharayat(Electrical Engineering 3rd Year)

Under Guidance of Mr. Vivek KumarAssistant ProfessorDepartment Of Computer ScienceTHDC Institute of Hydropower Engineering and TechnologyTehri Gharwal, UttarakhandIndia

Table of Contents

1. LIST OF FIGURE

2. ACKNOWLEDGEMENT

3. SOFTWARE REQUIREMENT

4. PROJECT SPECIFICATION

4.1. Objective 4.2. Project overview

5. CODE STRUCTURE

6. RESULT

7. REFERENCE & BIBLIOGRAPHY

LIST OF FIGURE

Figure 1Matlab R2010b GUI. Figure 2 Equation Animator GUI Window Figure 3 Equation Animator Graphic Window Figure 4 Equation Animator Edit GUI Window Figure 5 Equation Animator Blank GUI Window

ACKNOWLEDGEMENT

Wewould like to express our special thanks of gratitude to our professor Mr. Vivek Kumar, Assistant Professor, THDC IHET who gave us the golden opportunity to do this wonderful project on the topic Equation Animator Using Matlab, which also helped us in doing a lot of Research and we came to know about so many new things we are really thankful to him for showing us the real intersection of computer science and its application for engineers.

Charu Kandpal Ankur Sharma Rahul Singh Md. Gufran Hashmi

SOFTWARE REQUIREMENT :MATLAB

MATLABis a high-level language and interactive environment for numerical computation, visualization, and programming. Using MATLAB, you can analyze data, develop algorithms, and create models and applications. The language, tools, and built-in math functions enable you to explore multiple approaches and reach a solution faster than with spreadsheets or traditional programming languages, such as C/C++ or Java.

You can use MATLAB for a range of applications, including signal processing and communications, image and video processing, control systems, test and measurement, computational finance, and computational biology. More than a million engineers and scientists in industry and academia use MATLAB, the language of technical computing.

Fig. 1 Matlab R

Figure- GUI of Matlab 2010b

PROJECT SPECIFICATION

OBJECTIVETo make an equation animator which can animate the plot of binomial equation.

.PROJECT OVERVIEW

In our project we studied the basics of Matlab and GUIDE (Graphical User Interface Design Environment) that took almost 2 Month.

To find out information about my topic, we first started with the matlab basics and then GUIDE. After that we focused our main project i.e. how it works, did a lot of research on it from the previously did project on it and Mathworks, a privately held, multi-national corporation that specializes in mathematical computing software including MATLAB and Simulink.

The following topics we came to know-

GUIDE- GUIs (also known as graphical user interfaces or UIs) provide point-and-click control of software applications, eliminating the need to learn a language or type commands in order to run the application.MATLAB apps are self-contained MATLAB programs with GUI front ends that automate a task or calculation. The GUI typically contains controls such as menus, toolbars, buttons, and sliders. Many MATLAB products, such as Curve Fitting Toolbox, Signal Processing Toolbox, and Control System Toolbox, include apps with custom user interfaces. You can also create your own custom apps, including their corresponding UIs, for others to use.

Binomial Theorem- Binomial theoremis used to describe algebraic expression of power of a binomial, in elementary algebra. In other words binomial theorem can also be called as a quick way of expanding abinomial expressionthat have been raised to certain power.

CODE STRUCTUREAnimation Timer Callback Function-

function anim_timer_Callback(timer_object, eventdata, hObject)global hfig_mainglobal hfig_controlglobal hfig_graphics handles = guidata(hObject); % use local variables simplify equations x = hfig_main.params.x; y = hfig_main.params.y; a = hfig_main.params.a; % set the first element in vector x(n) and y(n) to the last element value from % the previous timer iteration x(1) = x(end); y(1) = y(end); % update graphics objects in graphics figure set(hfig_main.graphic_objects, 'XData', x, 'YData', y); % calculate N iterations for x(n) and y(n) for n = 1:hfig_main.params.N-1 % quadratic recursive equation x(n+1) = a(1) + a(2)*x(n) + a(3)*x(n)^2 + a(4)*x(n)*y(n) + a(5)*y(n) + a(6)*y(n)^2; y(n+1) = a(7) + a(8)*x(n) + a(9)*x(n)^2 + a(10)*x(n)*y(n) + a(11)*y(n) + a(12)*y(n)^2; if n == hfig_main.params.pos hfig_main.params.x_plot(hfig_main.params.count+1) = x(n); hfig_main.params.y_plot(hfig_main.params.count+1) = y(n); end end % check if x or y plot radiobutton is enabled and draw plots if hfig_main.params.xy_enable == 'x' plot(hfig_graphics.axes_plot, hfig_main.params.x_plot, '-k'); elseif hfig_main.params.xy_enable == 'y' plot(hfig_graphics.axes_plot, hfig_main.params.y_plot, '-k'); end % flush event queue and update graphics drawnow % save x and y params hfig_main.params.x = x; hfig_main.params.y = y; % update frame counter text set(hfig_graphics.text_count, ... 'String', ['Step Count, i = ' num2str(hfig_main.params.count)]); % update frame counter hfig_main.params.count = hfig_main.params.count + 1;

Push Button Run Callback-function pushbutton_run_Callback(hObject, eventdata, handles)global hfig_mainglobal hfig_controlglobal hfig_graphics % reset parameters hfig_main.params.x = zeros(hfig_main.params.N, 1); hfig_main.params.y = zeros(hfig_main.params.N, 1); hfig_main.params.x_plot = 0; % disable frame rate parameter controls, these can only be % modified when the timer is stopped set(hfig_control.edit_framerate, 'Enable', 'off'); set(hfig_control.slider_framerate, 'Enable', 'off'); % initialize graphics objects plot(hfig_graphics.axes_graphics, 0, 'k'); % reset plot set(hfig_graphics.axes_graphics, 'NextPlot', 'Add'); hfig_main.graphic_objects = plot(hfig_graphics.axes_graphics, ... hfig_main.params.x, ... hfig_main.params.y, ... 'Color', [1 1 1], ... 'LineStyle', 'none', ... 'Marker', '.'); % set nextplot property to ensure graphics screen is erased for % each frame set(hfig_graphics.axes_graphics, 'NextPlot', 'ReplaceChildren'); % start timer start(hfig_main.anim_timer);

Push Button Stop Callback-global hfig_mainglobal hfig_control stop(hfig_main.anim_timer); % enable frame rate parameter controls set(hfig_control.edit_framerate, 'Enable', 'on'); set(hfig_control.slider_framerate, 'Enable', 'on'); set(hfig_control.slider_framerate, 'Value', hfig_main.params.timer_fps);

Push Button Reset Callback-global hfig_mainglobal hfig_graphics % reset counter and x/y data hfig_main.params.x_plot = 0; hfig_main.params.y_plot = 0; hfig_main.params.count = 0; % time step counter hfig_main.params.x = zeros(hfig_main.params.N, 1); hfig_main.params.y = zeros(hfig_main.params.N, 1); set(hfig_graphics.text_count, ... 'String', ['Step Count, i = ' num2str(hfig_main.params.count)]); % reload current default parameters if isfield(hfig_main.params, 'file') eval(['run ' hfig_main.params.file ';']); else hfig_main.params.a = hfig_main.params.a_default; end update_controls;

Radio Button Callbak Function-Radio Button X-global hfig_mainglobal hfig_graphics val = get(hObject,'Value'); if val hfig_main.params.xy_enable = 'x'; set(hfig_main.radiobutton_y, 'Value', 0); end set(hfig_graphics.text_plot_title, ... 'String', [hfig_main.params.xy_enable ... ' position value for iteration = ' ... num2str(hfig_main.params.pos)]);Radio Button Y-global hfig_mainglobal hfig_graphics val = get(hObject,'Value'); if val hfig_main.params.xy_enable = 'y'; set(hfig_main.radiobutton_x, 'Value', 0); end set(hfig_graphics.text_plot_title, ... 'String', [hfig_main.params.xy_enable ... ' position value for iteration = ' ... num2str(hfig_main.params.pos)]);

RESULT

This is quite evident from the figure that Equation Animator using GUIDE in MATLAB has been done successfully.

Figure- Equation Animator Graphics

Figure- Equation Animator Edit GUI Window

Figure- Equation Animator Blank GUI Window

REFERENCE & BIBLIOGRAPHY

1. MATLAB For Engineers By H.Moore2. A MATLAB based Equation Animator by Abdul Khalid , Harvard University.3. Mathwork India-www.mathwork.in 4. Binomial Recursive Function By H.K.Dass5. Wikipedia : en.wi

CERTIFICATE

TO WHOMEVER IT MAY CONCERN

This is to certify that following students of THDC-IHET, Tehri have successfully completed and submitted their project in EQUATION ANIMATOR USING MATLAB.

Charu Kandpal (EE 3rd year) Ankur Sharma (EE 3rd year)

Rahul Singh (EE 3rd year) Md. Gufran Hashmi (EE 3rd year)

Mr.Vivek KumarAssistant ProfessorDepartment Of Computer scienceTHDC-IHET,Tehri.