Free Essay

Matlab and Ode Solvers

In:

Submitted By spence23
Words 828
Pages 4
Lab 0: MATLAB and ODE Solvers | ME 4173 Robot Kinematics

| | |

|

Introduction

The following report will display the results and conclusions of an experiment to simulate the output of an inverse pendulum system in MATLAB. The objectives of this experiment were to review MATLAB programming and using MATLAB to simulate ODEs and systems.
Objectives

* Examine the basics of MATLAB

* Use MATLAB to simulate a system

* Use ODE solvers to numerically integrate the system over a set time period
Apparatus
The apparatus used in this experiment was MATLAB. It was used to provide a simulation environment to analyze the inverse pendulum’s motion.
Experiments and Results
There were six components of this experiment. This experiment was mostly familiarizing with MATLAB. All code used is illustrated in the Appendix – Code.

The first part consisted of learning commands within the MATLAB environment. It was a brief overview of how commands work in MATLAB. There was no code used in the part of the experiment.

The second part of the experiment examined how arrays were created and used in MATLAB. The first step was to create a matrix. This matrix was then subjected to various commands including eye( ), zeroes( ), and ones( ). Indexing was also used to access various parts of the matrix. Matrix operations such as transpose, inverse, size and length were also shown.

Part three of the experiment explained how a script was created and what it was used for. A script file was created and used for other parts of the lab.
Part four illustrated what a function was and how they are created. It explained how syntax was important in the naming and calling of the function. This allowed the user to write a function and save in within a directory. This function could be called by the function name and input variables and return an answer depending on what the function was coded to perform. An addTwo(a,b) function was created as an example.

Part five contained the method for utilizing MATLAB`s ordinary differential equation solver (ODE). It uses this solver to perform numerical integration which allows systems to be solved within the MATLAB environment. MATLAB contains a number of ODE solvers: ode23, ode113, ode15s, ode23s, ode23t, ode23tb, ode45. An example of an ODE solver was used to illustrate the process of utilizing the solver.

Part six of the experiment was the simulation of an inverted pendulum. The pendulum was simulated using the ODE solver. Before the ODE solver could be used, the ordinary differential equations for the inverted pendulum needed to be developed and placed into state space variables. This was done by creating a function called xdot( ). The function has two element: xdot(1) and xdot(2). The two were plotted using a plot( ) function in MATLAB. The result was two sinusoidal waves which were cyclic in nature.
Discussion
The first problem which arose concerned the trigonometric functions within MATLAB. The code was written in degrees but the answer was expected to be in radians. It was giving a response which looked like an analog signal which was growing exponentially. Once the code was changed to display in radians, there was another issue. The code was checked by the TA and verified to be correct but the response was not what was expected. The issue was actually within MATLAB. Another MATLAB application was used with the same code and the issue was resolved.
Conclusion
The experiment was much more difficult than anticipated but that was due to small errors in syntax and in the software itself. The expected results were achieved in all questions of the experiment. The analysis of the inverted pendulum was completed using the ODE solver within MATLAB. The plot revealed two undamped sinusoidal waves which represented the angular velocity and angle of the system with a specific input.

Appendix- MATLAB Code * Part 2
A = [1 2 3 4 5; 6 7 8 9 10];
A(2,2)

A(1,end)

x = [1 2 3 4 5] x =
1 2 3 4 5 x(1) x(end)

inv(A)
A’
size(A) length(x) * Part 4 function var = addTwo(a,b) var = a + b;

addTwo(1,2)

* Part 5
Function
function ydot = rates(t,y) ydot(1,1) = y(3); ydot(2,1) = y(4); ydot(3,1) = -0.1; ydot(4,1) = 0.2;

Plotting y0 = [0;0;0;0]; %initial conditions tInitial = 0; %initial time tFinal = 10; %final time
[tout, yout] = ode23(’rates’,[tInitial tFinal],y0); % call to the ode solver

* Part 6
Function
% Function xdot with u = 0

function xdot = func(t,x) m = 2;
M = 8;
L = 1; g = 9.8; xdot = zeros(2,1); xdot(1) = x(2); xdot(2) = 2*g*sind(x(1))-m*L/(2*(m+M))*x(2)^2*sind(2*x(1))/(4*L/3-m*L*cosd(x(1))^2/(M+m));

Plotting Results close all clear all clc x = [5,0];

[tOut , xOut] = ode45(@func, [0 60], x);

plot (tOut, xOut)

Similar Documents

Free Essay

Ducation

...International Journal of Scientific Engineering and Research (IJSER) www.ijser.in ISSN (Online): 2347-3878 Volume 2 Issue 3, March 2014 Trajectory Tracking of a 2-Link Robotic Manipulator Using Adaptive Terminal Sliding Mode Controller Saurav Chanda1, Pranjal Gogoi2 1 Dept. of Electronics & Communication Engineering, Dibrugarh University Institute of Engineering & Technology Dibrugarh University, Assam, India 2 Dept. of Electronics & Communication Engineering, Dibrugarh University Institute of Engineering & Technology Dibrugarh University, Assam, India Abstract: This paper proposes an adaptive terminal sliding mode controller which combines adaptive control and sliding mode control to control a 2-link nonlinear robotic manipulator with uncertain parameters. We use an adaptive algorithm based on the concept of sliding mode control to alleviate the chattering phenomenon of control input. Adaptive laws are developed to obtain the gain of switching input and the boundary layer parameters. The stability and convergence of the robotic manipulator control system are guaranteed by applying the Lyapunov stability theorem. Simulation results demonstrate that the chattering of control input can be alleviated effectively. The proposed controller scheme can assure robustness against a large class of uncertainties and achieve good trajectory tracking performance. Keywords: Robotic manipulators, sliding mode control, adaptive law, Lyapunov stability theorem 1. Introduction ...

Words: 2637 - Pages: 11

Free Essay

Inverted Pendulem

...Committee Department of Mechanical Engineering Standup and Stabilization of the Inverted Pendulum by Andrew K. Stimac Submitted to the Department of Mechanical Engineering on May 5, 1999, in Partial Fulfillment of the Requirements for the Degree of Bachelor of Science in Mechanical Engineering. Abstract The inverted pendulum is a common, interesting control problem that involves many basic elements of control theory. This thesis investigates the standup routine and stabilization at the inverted position of a pendulum-cart system. The standup routine uses strategic cart movements to add energy to the system. Stabilization at the inverted position is accomplished through linear state feedback. Methods are implemented using the Matlab Simulink environment, with a dSPACE DSP controller board for...

Words: 6866 - Pages: 28

Premium Essay

Gsl Scientific Library

...GNU Scientific Library Reference Manual Edition 1.14, for GSL Version 1.14 4 March 2010 Mark Galassi Los Alamos National Laboratory Jim Davies Department of Computer Science, Georgia Institute of Technology James Theiler Astrophysics and Radiation Measurements Group, Los Alamos National Laboratory Brian Gough Network Theory Limited Gerard Jungman Theoretical Astrophysics Group, Los Alamos National Laboratory Patrick Alken Department of Physics, University of Colorado at Boulder Michael Booth Department of Physics and Astronomy, The Johns Hopkins University Fabrice Rossi University of Paris-Dauphine Copyright c 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The GSL Team. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being “GNU General Public License” and “Free Software Needs Free Documentation”, the Front-Cover text being “A GNU Manual”, and with the Back-Cover Text being (a) (see below). A copy of the license is included in the section entitled “GNU Free Documentation License”. (a) The Back-Cover Text is: “You have the freedom to copy and modify this GNU Manual.” Printed copies of this manual can be purchased from Network Theory Ltd at http://www.network-theory.co.uk/gsl/manual/. The money raised from sales of the manual...

Words: 148402 - Pages: 594

Free Essay

Physics

...Introductory Physics I Elementary Mechanics by Robert G. Brown Duke University Physics Department Durham, NC 27708-0305 rgb@phy.duke.edu Copyright Notice Copyright Robert G. Brown 1993, 2007, 2013 Notice This physics textbook is designed to support my personal teaching activities at Duke University, in particular teaching its Physics 141/142, 151/152, or 161/162 series (Introductory Physics for life science majors, engineers, or potential physics majors, respectively). It is freely available in its entirety in a downloadable PDF form or to be read online at: http://www.phy.duke.edu/∼rgb/Class/intro physics 1.php It is also available in an inexpensive (really!) print version via Lulu press here: http://www.lulu.com/shop/product-21186588.html where readers/users can voluntarily help support or reward the author by purchasing either this paper copy or one of the even more inexpensive electronic copies. By making the book available in these various media at a cost ranging from free to cheap, I enable the text can be used by students all over the world where each student can pay (or not) according to their means. Nevertheless, I am hoping that students who truly find this work useful will purchase a copy through Lulu or a bookseller (when the latter option becomes available), if only to help subsidize me while I continue to write inexpensive textbooks in physics or other subjects. This textbook is organized for ease of presentation and ease of learning. In particular, they are...

Words: 224073 - Pages: 897