Matlab and Ode Solvers

In: Other Topics

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

| | |



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.

* Examine the basics of MATLAB

* Use MATLAB to simulate a system

* Use ODE solvers to numerically integrate the system over a set time period
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…...

Similar Documents

Matlab Ode

...MATLAB 數值微積分與微分方程式求解 數值積分 ∫ b a f ( x) dx 等於由界限範圍 x = a 到 x = b 之間 曲線 f(x) 底下的面積 (a) 矩形以及 (b) 梯形 數值積分的圖解說明 數值積分 已知數據點的積分, 已知數據點的積分,不知函數 f(x):trapz : I = trapz(x, y) (梯形積分法 梯形積分法) 梯形積分法 x : 數據點之 x 值所構成的向量 y : 數據點之 f(x) 值所構成的向量 Ex: >>x=[0 10 20 30 40]; >>y=[0.5 0.7 0.9 0.6 0.4]; >>area=trapz(x,y) %梯形法 梯形法 area = 26.5000 數值積分 之形式: 已知函數 f(x) 之形式:quad , quadl I = quad(@fun, a, b) I = quadl(@fun, a, b) (適應性辛普森法) (羅伯特二次式) fun:定義函數的 function m-file 檔名 a :積分下限 b :積分上限 數值積分 Ex: ∫ 1 0 e − x cos( x) dx 1. edit fun.m function y=fun(x) y=exp(-x).*cos(x); 2. 求積分 回到Matlab Command Window) 求積分(回到 area=quadl(@fun,0,1) 亦可使用 area=quadl(‘exp(-x).*cos(x)’,0,1) NOTE: 函數內之數學運算必須使用向量個別元素之運算 (.* ./ .^) (註:比較此結果與利用trapz指令計算之結果) 數值微分 已知數據點的微分 在 x2 之微分 數值微分 可利用 diff 函數 Ex: >>x=0:0.1:1; >>y=[0.5 0.6 0.7 0.9 1.2 1.4 1.7 2.0 2.4 2.9 3.5]; >>dx=diff(x); >>dy=diff(y); >>dydx=diff(y)./diff(x) 數值微分 Ex: f ( x) = sin( x), f ′( x) = ? x ∈ [ 0, π ] >> >> >> >> >> >> >> x = linspace(0,pi,20); y = sin(x); d = diff(y)./diff(x); % backward or forward difference dc = (y(3:end)-y(1:end-2))./(x(3:end)-x(1:end-2)); % central difference dy = cos(x); % 實際微分值 plot(x, dy, x(2:end), d,'o', x(1:end-1), d,'x', x(2:end-1), dc,'^') xlabel('x'); ylabel('Derivative') 1 0.8 0.6 0.4 Derivative 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 0 0.5 1 1.5 x 2 2.5 3 3.5 工程問題中常微分方程式的解 常微分方程式 常微分方程式之形式: dy = f (t, y) dt 一般解之形式: yi +1 = yi + φ......

Words: 983 - Pages: 4


...matlab Probleme teoretice ale programării în MATLAB 1. Tipul de dată numeric. 2. Tipul de dată logic. 3. Tipul de dată caracter, şir de caractere. 4. Tipul de dată data şi ora. 5. Tipul de dată structură. 6. Tipul de dată celulă. 7. Expresii numerice şi logice în MATLAB. 8. Variabile în MATLAB. Definiţie şi tipuri de variabile. 9. Crearea variabilelor şi reguli de declarare a lor. 10. Cuvinte cheie. 11. operatori şi reguli de precedenţă. 12. Constante speciale în MATLAB. 13. Matrici, vectori, scalari. Funcţia size. Crearea cu operatorul []. 14. Crearea matricelor cu funcţii speciale. 15. Concatenarea matricelor. 16. Crearea matricelor cu blocuri pe diagonală 17. Accesarea directă şi liniară a matricelor. 18. Accesarea multiplă (cu operatorul :). 19. Accesarea logic indexată. 20. Funcţii de matrici şi funcţii de manipulare a matricelor. 21. Comanda de atribuire. Comenzi de întrerupere a execuţiei buclelor. 22. Comenzi de execuţie condiţionată. 23. Comenzi de execuţie a ciclurilor. 24. M-programe (M-scripturi şi M-funcţii) 25. Erori. Exportul şi importul datelor. Listarea pe ecran. 26. Depanarea M-programelor. 27. Utilizarea eficientă a memoriei. 28. Analiza timpului de execuţie şi principalele tehnici de reducere a timpului de execuţie. 29. Modelarea cu blocuri şi conexiuni în Simulink 30. Cele mai utilizate blocuri din biblioteca de blocuri Simulink. 1. Să se......

Words: 1953 - Pages: 8

Ode to a Nightingale

...Examination of John Keats’ Ode to a Nightingale Outline and Thesis of “Ode to A Nightingale” by John Keats. Thesis: John Keats correlated the nightingale’s transcendent song with man’s desire for immortality. I. Brief History of Poem A. Outline details, including when, where written. B. Outline interesting relevant historical facts II. Break down of poem – stanza by stanza A. Include description of title. B. Identify rhyme and metrical device employed in poem. C. Include theme, setting description. D. Identify literary devices utilized by Keats III. Closing Analysis A. Speculate about Keats ultimate inspiration. B. Relate inspiration theme to Ode to a Nightingale theme. C. Close with analysis of irony of respective poems compared. D. Repeat thesis statement in closing for synchronicity of essay. Written in May of 1819, “Ode to a Nightingale” was one of five “odes” written by John Keats during that year [1]. The poem, which was published July of the same year in the Annals of Fine Art, was originally titled “Ode to the Nightingale”, but was apparently changed by the publisher twenty years following the death of John Keats(reference here) . According to a recollection of Keats’ good friend, Charles Brown, Keats’ inspiration for the poem came while sitting under a plum tree growing upon Hampstead Heath. There, Keats was said to be mesmerized by the melodic song of a nightingale who proved...

Words: 1227 - Pages: 5


...Matlab Assignment 7 Make the Matalb assignment discussed in the last class (least square regression estimates). Make sure that you program a function with proper comments and at least one test for sound input. Test your function with some input vectors, for example: y=[1,2,4,23,4,6,3,2] and x=[5,4,3,2,6,5,4,3] You can take any other input vectors. m.file command: function [alpha_estimate, beta_estimate] = my_regression(y,x) n = length(x) a = sum(x); b = sum(y); c = sum(x)/n; d = sum(y)/n; e = sum(x.*y); f = sum(x.*x); alpha_estimate = d-(e-n*c*d)/(f-n*c^2)*c; beta_estimate = (e-n*c*d)/(f-n*c^2); disp('alpha =') disp(alpha_estimate) disp('beta =') disp(beta_estimate) % Purpose of the function: This function is used to calculate the % coefficients of the regression formula. % Input: value of y and x % Output: alpha_estimate and beta_estimate % How to run the function: % I use n to represent the length of vector x and y % a to represent the sum of vector x % b to represent the sum of vector y % c to represent the avergae of vector x % d to represent the average of vector y % e to represent the sum of vector x and y % f to represent the sum of square of vector x %then calculating: alpha_estimate = d-(e-n*c*d)/(f-n*c^2)*c; % beta_estimate = (e-n*c*d)/(f-n*c^2); % Author: Hengya Jin % Date of last change: 11/27/2013 end Check: >>......

Words: 298 - Pages: 2


...Declaración de variables var y1 binary; var y2 binary; var y3 binary; var y4 binary; var y5 binary; var y6 binary; # Función objetivo minimize objetivo: y1+y2+y3+y4+y5+y6 ; # Restricciones asociadas a la distancia entre ciudades subject to res_ciudad_1: y1+y2 >= 1; subject to res_ciudad_2: y1+y2+y6 >= 1; subject to res_ciudad_3: y3+y4 >= 1; subject to res_ciudad_4: y3+y4+y5 >= 1; subject to res_ciudad_5: y4+y5+y6 >= 1; subject to res_ciudad_6: y2+y5+y6 >= 1; Fichero ### Práctica 8a # Problema del libro de Winston, página 478, ejemplo 5 # Problema de cobertura de conjuntos en formato 1 # Fichero reset; model A:\practica8a.mod; option solver cplex; solve; display objetivo; display y1,y2,y3,y4,y5,y6; Solución obtenida con el programa AMPL: CPLEX 8.0.0: optimal solution; objective 2 4 dual simplex iterations (0 in phase I) objetivo = 2 y1 = 0, y2 = 1, y3 = 0, y4 = 1, y5 = 0, y6 = 0; PRÁCTICA 8B Problema de cobertura de conjuntos, Winston página 478, ejemplo 5, formato2. Fichero práctica8b.mod ### Práctica 8b # Problema del libro de Winston, página 478, ejemplo 5 # Problema de cobertura de conjuntos en formato 2 # Fichero practica8b.mod # Declaración de variables param m; param n; set CLIENTES:=1..m; set SERVIDORES:=1..n; var y{SERVIDORES} binary; # Función objetivo minimize objetivo: sum {j in SERVIDORES} y[j] ; # Restricciones......

Words: 2124 - Pages: 9

Lp Solver

...Spreadsheet Chapter 3 C.T. Ragsdale. 2008. Spreadsheet Modeling & Decision Analysis, 5th E. Revised, Thompson 1 Section 1 EXCEL SOLVER 2 Introduction • Solving LP problems graphically is only possible when there are two decision variables • Few real-world LP have only two decision variables • Fortunately, we can now use spreadsheets to solve LP problems 3 LP Solvers • Conventional – MPS (IBM) – LINDO, GINO – GAMS – AMPL • Algebraic Language • Spreadsheet Modeling • The company that makes the Solver in Excel, Lotus 12-3, and Quattro Pro is Frontline Systems, Inc. Check out their web site: – Frontline Solver, Premium Solver, Risk Solver – What’s Best? 4 Steps in Implementing an LP Model in a Spreadsheet 1. Organize the data for the model on the spreadsheet. 2. Reserve separate cells in the spreadsheet for each decision variable in the model. 3. Create a formula in a cell in the spreadsheet that corresponds to the objective function. 4. For each constraint, create a formula in a separate cell in the spreadsheet that corresponds to the left-hand side (LHS) of the constraint. 5 The Simple Farm Model Again! max π = x1 + 1.5x2 s/t x1 + 2x2 ≤ 160 3x1 + 2x2 ≤ 240 x1 ≥ 0, x2 ≥ 0 6 Implementing the Model See file FarmEx original.xls 7 Cell Labels 8 How Solver Views the Model • Target cell - the cell in the spreadsheet that represents the objective function • Changing cells - the cells in......

Words: 2610 - Pages: 11


...PARTH  PATTNI     BIOENGINEERING-­‐MATLAB  ASSIGNEMENT   a) figure subplot(2,1,1) plot(ecg_emg) ylabel('Voltage,V/mV') xlabel('Time,t/ms') title('ECG which is contaminated with EMG signals from the diaphragm') axis([0 3000 -1 2]) subplot(2,1,2) plot(ecg50hz) xlabel('Time,t/ms') ylabel('Voltage,V/mV') title('ECG containing mains contamination') axis([0 3000 -1 2]) PARTH  PATTNI     BIOENGINEERING-­‐MATLAB  ASSIGNEMENT   b & c) figure subplot(2,1,1) length=5; for x=1:3000-length+1; zecg_emg(x)=(ecg_emg(x)+ecg_emg(x+1)+ecg_emg(x+2)+ecg_emg(x+3)+ ecg_emg(x+4))/5; end plot(ecg_emg) ylabel('Voltage,V/mV') xlabel('Time,t/ms') title('ECG which is contaminated with EMG signals from the diaphragm') axis([0 3000 -1 2]) subplot(2,1,2) length=5; for x=1:3000-length+1; zecg50hz(x)=(ecg50hz(x)+ecg50hz(x+1)+ecg50hz(x+2)+ecg50hz(x+3)+ecg 50hz(x+4))/5; end plot(ecg50hz) xlabel('Time,t/ms') ylabel('Voltage,V/mV') title('ECG containing mains contamination') PARTH  PATTNI     BIOENGINEERING-­‐MATLAB  ASSIGNEMENT   axis([0 3000 -1 2]) d) figure subplot(2,1,1) length=3; for x=1:3000-length+1; zecg_emg(x)=(ecg_emg(x)+ecg_emg(x+1)+ecg_emg(x+2))/3; end plot(zecg_emg) ylabel('Voltage,V/mV') xlabel('Time,t/ms') title('ECG which is contaminated with EMG signals from the diaphragm') PARTH  PATTNI     BIOENGINEERING-­‐MATLAB  ASSIGNEMENT   axis([0 3000 -1......

Words: 645 - Pages: 3

Problem Solver

...Problem Solver I chose problem solver because I have realized in my life that is what I love to do. I love to solve problems. I have a hard time practicing or participating in activities that don’t have a sense of purpose. But if there is a problem, I obsess over it until it is resolved. The problem that I decided to put through the five step process was with the problem I had after graduating with my B.S. degree. I graduated in December of 2011, right in the middle of so many problems with people being able to get jobs. At the time I was working in a field that I would say was about 20% related to my degree. My degree is in Electronics Engineering and I was working in a power plant, however it was a methane gas power plant and the majority of what I did was mechanical maintenance. Not liking where I was and not able to get more than a few interviews, I was stuck. Either I was too qualified, the job didn’t pay enough, or I was under qualified. Step 1: The main problem was job placement, there were many factors but in the end I was not in a place that I wanted to be in my career. Step 2: The causes were many, as I mentioned earlier. * Under/over qualified * Weak jobs market * Pay associated with available jobs * Nowhere to go with current job, or lack of desire to do so I also at this time began to realize that I didn’t like where my experience was taking me. I had now worked in two jobs that were in an industrial setting, (large machinery, noisy, dirty...

Words: 623 - Pages: 3


...A、B 机器加工,加工时间分别为每台 2 小时和 1 小时;生产乙机床 需用 A、B、C 三种机器加工, 加工时间为每台各一小时。 若每天可用于加工的机器时 数分别为 A 机器 10 小时、 B 机器 8 小时和 C 机器 7 小时,问该厂应生产甲、乙机床各 几台,才能使总利润最大? 上述问题的数学模型: 设该厂生产 x1 台甲机床和 x 2 乙机床时总利润最大, x1 , x2 则 应满足 (目标函数) max z = 4 x1 + 3 x2 (1) ⎧2 x1 + x2 ≤ 10 ⎪x + x ≤ 8 ⎪ 1 2 s.t.(约束条件) ⎨ ⎪ x2 ≤ 7 ⎪ x1 , x2 ≥ 0 ⎩ (2) (1)式被称为问题的目标函数, (2)中的几个不等式 这里变量 x1 , x 2 称之为决策变量, 是问题的约束条件,记为 s.t.(即 subject to)。由于上面的目标函数及约束条件均为线性 函数,故被称为线性规划问题。 总之, 线性规划问题是在一组线性约束条件的限制下, 求一线性目标函数最大或最 小的问题。 在解决实际问题时, 把问题归结成一个线性规划数学模型是很重要的一步, 但往往 也是困难的一步,模型建立得是否恰当,直接影响到求解。而选适当的决策变量,是我 们建立有效模型的关键之一。 1.2 线性规划的 Matlab 标准形式 线性规划的目标函数可以是求最大值, 也可以是求最小值, 约束条件的不等号可以 是小于号也可以是大于号。为了避免这种形式多样性带来的不便,Matlab 中规定线性 规划的标准形式为 min cT x x ⎧ Ax ≤ b ⎪ s.t. ⎨ Aeq ⋅ x = beq ⎪lb ≤ x ≤ ub ⎩ 其中 c 和 x 为 n 维列向量, A 、 Aeq 为适当维数的矩阵, b 、 beq 为适当维数的列向 量。 -1- 例如线性规划 Ax ≥ b max cT x s.t. x 的 Matlab 标准型为 min − cT x s.t. x − Ax ≤ −b 1.3 线性规划问题的解的概念 一般线性规划问题的(数学)标准型为 n z = ∑cj xj max (3) j =1 s.t. 可行解 ⎧n ⎪∑ aij x j = bi i = 1,2, L, m ⎨ j =1 ⎪ x ≥ 0 j = 1,2,L, n ⎩ j (4) 满足约束条件 (4) 的解 x = ( x1 , x2 , L , xn ) , 称为线性规划问题的可行解, 而使目标函数(3)达到最大值的可行解叫最优解。 可行域 所有可行解构成的集合称为问题的可行域,记为 R 。 1.4 线性规划的图解法 10 2 x1 + x2 = 1 0 9 8 7 x2 = 7 (2 ,6 ) 6 5 4 3 2 x1 + x2 = 8 1 z= 1 2 0 0 2 4 6 8 10 图 1 线性规划的图解示意图 图解法简单直观, 有助于了解线性规划问题求解的基本原理。 我们先应用图解法来 求解例 1。对于每一固定的值 z ,使目标函数值等于 z 的点构成的直线称为目标函数等 位线,当 z 变动时,我们得到一族平行直线。对于例...

Words: 57838 - Pages: 232


...C1: MATLAB Codes t1=[37.79 39.51 38.54 39.14 39.02 39.4 39.01 37.18] t2=[22.4 22.07 22.15 21.72 21.75 22.55 22.18 21.92] T1=mean(t1) T2=mean(t2) V1=var(t1) V2=var(t2) S1=sqrt(V1) S2=sqrt(V2) MATLAB Answers T1=38.6988 T2=22.0925 V1=0.6718 V2=0.0859 S1=0.8196 S2=0.2931 C2: MATLAB Codes beta=0.98 alpha=1-0.98 z=icdf ('norm', alpha/2, 0, 1) hatmu=mean(t1); hatmu=mean(t2) s=std(t1); s=std(t2) n=length (t1); n=length (t2) margin=z*s/sqrt(8) MATLAB Answers alpha=0.02 z=2.3263 margin(t1)=0.6741; margin(t2)=0.2931 C3: MATLAB Codes syms l s b T1 T2 l=0.0496; s=1.00; b=10; T1=0.0386988; T2=0.0220925; g=((l^2)/(2*s*sind(b)))*((1/T2^2)-(1/T1^2)) MATLAB Answers g=9.7835 C4: MATLAB Codes for Partial Derivatives g=((l^2)/(2*s*sin(b)))*((1/T2^2)-(1/T1^2)) gl=diff(g,l) gs=diff(g,s) gb=diff(g,b) gT1=diff(g,T1) gT2=diff(g,T2) MATLAB Answers for Partial Derivatives gl=-(l*(1/T1^2 - 1/T2^2))/(s*sin(b)) gs=(l^2*(1/T1^2 - 1/T2^2))/(2*s^2*sin(b)) gb=(l^2*cos(b)*(1/T1^2 - 1/T2^2))/(2*s*sin(b)^2) gT1=l^2/(T1^3*s*sin(b)) gT2=-l^2/(T2^3*s*sin(b)) MATLAB Codes for Partial Derivative Values gl0=subs(gl,[l s b T1 T2],[l0 s0 b0 T10 T20]) gs0=subs(gs,[l s b T1 T2],[l0 s0 b0 T10 T20]) gb0=subs(gb,[l s b T1 T2],[l0 s0 b0 T10 T20]) gT10=subs(gT1,[l s b T1 T2],[l0 s0 b0 T10 T20]) gT20=subs(gT2,[l s b T1 T2],[l0 s0 b0 T10 T20]) MATLAB Answers for Partial Derivative Values gl0=......

Words: 455 - Pages: 2

Matlab & Ss

...Lab 1: Introduction to MATLAB Warm-up MATLAB is a high-level programming language that has been used extensively to solve complex engineering problems. The language itself bears some similarities with ANSI C and FORTRAN. MATLAB works with three types of windows on your computer screen. These are the Command window, the Figure window and the Editor window. The Figure window only pops up whenever you plot something. The Editor window is used for writing and editing MATLAB programs (called M-files) and can be invoked in Windows from the pull-down menu after selecting File | New | M-file. In UNIX, the Editor window pops up when you type in the command window: edit filename (‘filename’ is the name of the file you want to create). The command window is the main window in which you communicate with the MATLAB interpreter. The MATLAB interpreter displays a command >> indicating that it is ready to accept commands from you. • View the MATLAB introduction by typing >> intro at the MATLAB prompt. This short introduction will demonstrate some basic MATLAB commands. • Explore MATLAB’s help capability by trying the following: >> help >> help plot >> help ops >> help arith • Type demo and explore some of the demos of MATLAB commands. • You can use the command window as a calculator, or you can use it to call other MATLAB programs (M-files). Say you want to evaluate the expression [pic], where a=1.2, b=2.3, c=4.5 and d=4....

Words: 2151 - Pages: 9


...Lab 2: Linear Time-Invariant Systems In this experiment, you will study the output response of linear time-invariant (LTI) systems using MATLAB, and learn how to use MATLAB to implement the convolution sum. You will also investigate the properties of LTI systems. The objective of this experiment is: (1) to study how to compute the output of LTI systems, and (2) to study the properties of discrete-time LTI systems. 1. Introduction to Linear Time-Invariant (LTI) Systems In discrete time, linearity provides the ability to completely characterize a system in terms of its response [pic] to a signal of the form [pic] for all [pic]. If a linear system is also time-invariant, then the responses [pic] will become [pic]. The combination of linearity and time-invariance therefore allows a system to be completely described by its impulse response [pic]. The output of the system [pic] is related to the input [pic] through the convolution sum as follows: [pic] Similarly, the output [pic] of a continuous-time LTI system is related to the input [pic] and the impulse response [pic] through the following convolution integral: [pic] The convolution of discrete-time sequences [pic] and [pic] represented mathematically by the expression given in [pic] can be viewed pictorially as the operation of flipping the time axis of the sequence [pic] and shifting it by [pic] samples, then multiplying [pic] by[pic] and summing the resulting product......

Words: 1592 - Pages: 7


...Memulai Menggunakan Matlab Matlab merupakan bahasa canggih untuk komputansi teknik. Matlab merupakan integrasi dari komputansi, visualisasi dan pemograman dalam suatu lingkungan yang mudah digunakan, karena permasalahan dan pemecahannya dinyatakan dalam notasi matematika biasa. Kegunaan Matlab secara umum adalah untuk : • • • • • Matematika dan Komputansi Pengembangan dan Algoritma Pemodelan,simulasi dan pembuatan prototype Analisa Data,eksplorasi dan visualisasi Pembuatan apilikasi termasuk pembuatan graphical user interface Matlab adalah sistem interaktif dengan elemen dasar array yang merupakan basis datanya. Array tersebut tidak perlu dinyatakan khusus seperti di bahasa pemograman yang ada sekarang. Hal ini memungkinkan anda untuk memecahkan banyak masalah perhitungan teknik, khususnya yang melibatkan matriks dan vektor dengan waktu yang lebih singkat dari waktu yang dibutuhkan untuk menulis program dalam bahasa C atau Fortran. Untuk memahami matlab, terlebih dahulu anda harus sudah paham mengenai matematika terutama operasi vektor dan matriks, karena operasi matriks merupakan inti utama dari matlab. Pada intinya matlab merupakan sekumpulan fungsi-fungsi yang dapat dipanggil dan dieksekusi. Fungsi-fungsi tersebut dibagi-bagi berdasarkan kegunaannya Kuliah Berseri IlmuKomputer.Com Copyright © 2004 IlmuKomputer.Com yang dikelompokan didalam toolbox yang ada pada matlab. Untuk mengetahui lebih jauh mengenai toolbox yang ada di matlab dan......

Words: 2781 - Pages: 12


...An Introduction to Matlab for Econometrics John C. Frain TEP Working Paper No. 0110 February 2010 Trinity Economics Papers Department of Economics Trinity College Dublin An Introduction to MATLAB for Econometrics John C. Frain. February 2010 ∗ Abstract This paper is an introduction to MATLAB for econometrics. It describes the MATLAB Desktop, contains a sample MATLAB session showing elementary MATLAB operations, gives details of data input/output, decision and loop structures, elementary plots, describes the LeSage econometrics toolbox and maximum likelihood using the LeSage toolbox. Various worked examples of the use of MATLAB in econometrics are also given. After reading this document the reader should be able to make better use of the MATLAB on-line help and manuals. Contents 1 Introduction 1.1 1.2 Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The MATLAB Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 ∗ Comments 4 4 6 6 7 8 8 9 9 9 The Command Window . . . . . . . . . . . . . . . . . . . . . . . . The Command History Window . . . . . . . . . . . . . . . . . . . The Start Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Edit Debug window . . . . . . . . . . . . . . . . . . . . . . . . The Figure Windows . . . . . . . . . . . . . . . . . . . . . . . . . . The Workspace Browser . . . . . . . . . . . . . . . . . . . . . . . .......

Words: 15376 - Pages: 62

Ode to Autumn

...Conspiring with him how to load and bless With fruit the vines that round the thatch-eves run; * Ah, so now the sun and autumn are "conspiring," eh? Looks like we might have to separate the two of them. What are they whispering about over there? * OK, so not quite as thrilling as we thought. They are planning how to make fruit grow on the vines that curl around the roofs ("eves") of thatched cottages. * The image highlights the weight of the fruit as it "loads" down the vines. * Thatched cottages suggest a pastoral setting, characterized by shepherds, sheep, maidens, and agriculture. The "pastoral" as a literary genre was thought to originate in Ancient Greece, and the ode is a Greek form, so it is appropriate for this ode to include pastoral themes. Keats's other Great Odes, especially "Ode on a Grecian Urn," include similar imagery. Lines 5-6 To bend with apples the moss'd cottage-trees, And fill all fruit with ripeness to the core; * Keats is going nuts (pun!) with images of weight and ripeness. The richness here is like Willy Wonka's Chocolate Factory set in an orchard. * The apples "bend" down the branches of mossy trees with their weight. The trees belong not to some big farming cooperative, but to the simple cottages of country folk. * The ripeness penetrates deep to the very center of the fruit. They're not like those apples that look delicious until you take a bite and realize that the fruit is hard and sour. No, these babies are......

Words: 3356 - Pages: 14