diff --git a/final_project/README.md b/final_project/README.md new file mode 100644 index 0000000..cee3ee3 --- /dev/null +++ b/final_project/README.md @@ -0,0 +1,103 @@ +# ME 3255 - Final Project +## Due May 1 by 11:59pm + +In this project you are going to solve for the shape of a beam under different loading +conditions. The shape of the beam varies along the x-axis and as a function of time. + +Notes: Label the plots with legends, x- and y-axis labels and make sure the plots are easy +to read (you can use the `setdefaults.m` script we have used in class). All functions +should have a help file and your README.md should describe each file in your repository +and provide a description of each problem and each solution (use `#`-headings in your file +to show the start of new problems) + +You will be graded both on documentation and implementation of the solutions. + +![Diagram of beam and loading conditions](beam.png) + +We will use the Euler-Bernoulli beam equation to describe the shape of the beam, the +differential equation that governs the solution is: + +$\frac{\partial^4 w}{\partial x^4}-\frac{P}{EI}\frac{\partial^2 w}{\partial +x^2}+\frac{\rho A}{EI}\frac{\partial^2 w}{\partial t^2}=q(x)$ (1) + +Where w(x,t) is the displacement of the beam away from the neutral axis as a function of +position along the beam, x, and time, t, P is the transverse loading of the beam, E is the +Young's modulus, I is the second moment of Inertia of the beam, $\rho$ is the density, A +is the cross-sectional area, and q(x) is the transverse distributed load (for a uniform +pressure, it is the applied pressure times the width of the beam, in units of +force/length). + +We can separate the function $w(x,t)=w(x)e^{i\omega t}$, now equation (1) becomes + +$\left(\frac{\partial^4 w}{\partial x^4}-\frac{P}{EI}\frac{\partial^2 w}{\partial +x^2}-\frac{\rho A \omega^{2}}{EI}w\right)e^{i\omega t}=\frac{q(x)}{EI}$ (2) + +For the simply-supported beam shown in Figure 1, the boundary conditions are: + +$w(0)=w(L)=0$ + +$w''(0)=w''(L)=0$ + +The material is aluminum, E=70 GPa, $\rho$=2700 kg/m$^3$. The bar is 1-m-long with a base +width, b=0.1 m, and height, h=0.01 m, and the second moment of inertia, +I=$\frac{bh^3}{12}$. + +1. Analytically solve for the shape of the beam if q(x)=cst, P=0, and $\omega$=0 and +create a function called `shape_simple_support.m` that returns the displacement w(x) given +q and x + +``` +w=shape_simple_support(x,q); +``` + +a. Plot q vs the maximum deflection, $\delta x$, of the beam + +b. Use a Monte Carlo model to determine the mean and standard deviation for the +maximum deflection $\delta x$ if b and h are normally distributed random variables +with 0.1 % standard deviations at q=50 N/m. + +3. Now use the central difference approximation to set up a system of equations for the +beam for q(x)=cst, P=0, and $\omega=0$. Use the boundary conditions with a numerical +differentiation to determine the valuea of the end points + + a. set up the system of equations for 6 segments as a function of q + + b. set up the system of equations for 10 segments as a function of q + + c. set up the system of equations for 20 segments as a function of q + + d. solve a-c for q=1,10,20,30,50 and plot the numerical results of q vs $\delta x$ + + e. Comment on the results from the analytical and numerical approaches (if you used + functions then provide help files, if you used scripts, then describe the steps used) + +4. Now set up the system of equations using a central difference method if P>0 and +$\omega=0$ + + a. set up the system of equations for 6 segments as a function of q and P + + b. set up the system of equations for 10 segments as a function of q and P + + c. set up the system of equations for 20 segments as a function of q and P + + d. solve a-c for q=1,10,20,30,50 and plot the numerical results of q vs $\delta x$ for + P=0, 100, 200, 300 (4 lines, labeled as P=0,P=100,...) + +5. Now set up an eigenvalue problem to solve for the natural frequencies of the simply +supported beam if P=0 and q=0. + + a. set up the system of equations for 6 segments + + b. set up the system of equations for 10 segments + + c. set up the system of equations for 20 segments + + d. solve for the natural frequencies ($\omega_{1}$, $\omega_{2}$,...) + + e. Plot the shape of the beam for the first 3 natural frequencies + +6. (Bonus 5pt) Create a function to return the system of equations for the eigenvalue +problem as a function of P, if P>0. Then, plot the lowest natural frequency vs the applied +load P. + + diff --git a/final_project/beam.png b/final_project/beam.png new file mode 100644 index 0000000..271d614 Binary files /dev/null and b/final_project/beam.png differ diff --git a/final_project/beam.svg b/final_project/beam.svg new file mode 100644 index 0000000..b02b62d --- /dev/null +++ b/final_project/beam.svg @@ -0,0 +1,615 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + q(x) + P + P + + + w(x) + + + x + y + + diff --git a/final_project/final_project.pdf b/final_project/final_project.pdf new file mode 100644 index 0000000..3df5f1f Binary files /dev/null and b/final_project/final_project.pdf differ diff --git a/final_project/rubric.md b/final_project/rubric.md new file mode 100644 index 0000000..08248bd --- /dev/null +++ b/final_project/rubric.md @@ -0,0 +1,27 @@ +# Grading Rubric + +| Component | Grade | Description | +| --------- |------ |--------------------------------- | +|Solutions | 50 % | Problems are solved correctly and solution makes sense | +|Documentation| 30 % | All files have comments and all functions have help files | +|Problem Statements | 10% | Descriptions of each problem and the approach | +|Team Work | 10% | Each group member made commits to repository| +|Github Bonus | 5% | If a group member opens an [issue](https://guides.github.com/features/issues/) and you commit code to close it| + +The Documentation and Problem Statements will be assessed based upon the included m-files +and the main README.md documentation. This is a final report, so make sure the README.md +is easy to understand with headers (`#`, `##`, ...) to start each problem and sub-problem. + +The Solutions will be graded based upon correctness and the approach. The plots will be +graded based upon the axis labels, titles, legend, correctness, and design. +If you are asked to solve for a value, you can choose to put it in a table or in a +paragraph, but it must be easy to read/understand. + +The Team Work section is meant to demonstrate working knowledge of Github (now as a +collaborative project). If everyone makes commits to the project, then you will receive +credit. + +The Github Bonus requires extra reading. Create an issue and tag your group member. That +group member can then respond and *fix* the issue with a commit. This is a bonus 5pts (on +an individual basis, for everyone to get credit, everyone in the group would need to close +an issue) diff --git a/lecture_20/.ipynb_checkpoints/lecture_20-checkpoint.ipynb b/lecture_20/.ipynb_checkpoints/lecture_20-checkpoint.ipynb new file mode 100644 index 0000000..2fd6442 --- /dev/null +++ b/lecture_20/.ipynb_checkpoints/lecture_20-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/lecture_20/gauss_weights.png b/lecture_20/gauss_weights.png new file mode 100644 index 0000000..9e3f29d Binary files /dev/null and b/lecture_20/gauss_weights.png differ diff --git a/lecture_20/lecture_20.ipynb b/lecture_20/lecture_20.ipynb new file mode 100644 index 0000000..da8c4ac --- /dev/null +++ b/lecture_20/lecture_20.ipynb @@ -0,0 +1,2192 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 152, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "setdefaults" + ] + }, + { + "cell_type": "code", + "execution_count": 153, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "%plot --format svg" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Questions from last class\n", + "\n", + "The interp2 function uses splines to interpolate between data points. What are three options for interpolation:\n", + "\n", + "- cubic spline\n", + "\n", + "- piecewise cubic spline\n", + "\n", + "- linear spline\n", + "\n", + "- quadratic spline\n", + "\n", + "- fourth-order spline\n", + "\n", + "![q1](q1.png)\n", + "\n", + "Numerical integration is a general application of the Newton-Cotes formulas. What is the first order approximation of the Newton-Cotes formula? *\n", + "\n", + "- trapezoidal rule\n", + "\n", + "- Simpson's 1/3 rule\n", + "\n", + "- Simpson's 3/8 rule\n", + "\n", + "- linear approximation of integral\n", + "\n", + "- constant approximation of integral (sum(f(x)*dx))\n", + "\n", + "![q2](q2.png)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Questions from you\n", + "\n", + "- Is spring here to stay?\n", + " \n", + " - [Punsxatawney Phil](http://www.groundhog.org/)\n", + "\n", + "- The time is now.\n", + "\n", + "- Final Project Sheet?\n", + " \n", + " - coming this evening/tomorrow\n", + "\n", + "- can you provide some sort of hw answer key?\n", + " \n", + " - we can go through some of the HW \n", + "\n", + "- What's the most 1337 thing you've ever done?\n", + "\n", + " - sorry, I'm n00b to this\n", + "\n", + "- Can we do out more examples by hand (doc cam or drawing on computer notepad) instead of with pre-written code?\n", + "\n", + " - forthcoming\n", + "\n", + "- Favorite movie?\n", + " \n", + " - Big Lebowski\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Integrals in practice\n", + "\n", + "### Example: Compare toughness of Stainless steel to Structural steel\n", + "\n", + "![Stress-strain plot of steel](steel_psi.jpg)\n", + "\n", + "### Step 1 - G3Data to get points \n", + "\n", + "Use the plot shown to determine the toughness of stainless steel and the toughness of structural steel.\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 154, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "toughness of structural steel is 10.2 psi\n", + "toughness of stainless steel is 18.6 psi\n" + ] + } + ], + "source": [ + "fe_c=load('structural_steel_psi.jpg.dat');\n", + "fe_cr =load('stainless_steel_psi.jpg.dat');\n", + "\n", + "fe_c_toughness=trapz(fe_c(:,1),fe_c(:,2));\n", + "fe_cr_toughness=trapz(fe_cr(:,1),fe_cr(:,2));\n", + "\n", + "fprintf('toughness of structural steel is %1.1f psi\\n',fe_c_toughness)\n", + "fprintf('toughness of stainless steel is %1.1f psi',fe_cr_toughness)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Gauss Quadrature (for functions)\n", + "\n", + "Evaluating an integral, we assumed a polynomial form for each Newton-Cotes approximation.\n", + "\n", + "If we can evaluate the function at any point, it makes more sense to choose points more wisely rather than just using endpoints\n", + "\n", + "![trapezoidal example](trap_example.png)\n", + "\n", + "Let us set up two unknown constants, $c_{0}$ and $x_{0}$ and determine a *wise* place to evaluate f(x) such that \n", + "\n", + "$I=c_{0}f(x_{0})$\n", + "\n", + "and I is exact for polynomial of n=0, 1\n", + "\n", + "$\\int_{a}^{b}1dx=b-a=c_{0}$\n", + "\n", + "$\\int_{a}^{b}xdx=\\frac{b^2-a^2}{2}=c_{0}x_{0}$\n", + "\n", + "so $c_{0}=b-a$ and $x_{0}=\\frac{b+a}{2}$\n", + "\n", + "$I=\\int_{a}^{b}f(x)dx \\approx (b-a)f\\left(\\frac{b+a}{2}\\right)$\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 155, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "f1 =\n", + "\n", + "@(x) x + 1\n", + "\n", + "f2 =\n", + "\n", + "@(x) 1 / 2 * x .^ 2 + x + 1\n", + "\n", + "f3 =\n", + "\n", + "@(x) 1 / 6 * x .^ 3 + 1 / 2 * x .^ 2 + x\n", + "\n" + ] + }, + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "Gnuplot\n", + "Produced by GNUPLOT 5.0 patchlevel 3 \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1000\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-500\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t500\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1000\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1500\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-20\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-15\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-10\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t10\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t15\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t20\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\n", + "\n", + "\tgnuplot_plot_1a\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "f1=@(x) x+1\n", + "f2=@(x) 1/2*x.^2+x+1\n", + "f3=@(x) 1/6*x.^3+1/2*x.^2+x\n", + "plot(linspace(-18,18),f3(linspace(-18,18)))" + ] + }, + { + "cell_type": "code", + "execution_count": 156, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "integral of f1 from 2 to 3 = 3.500000\n", + "integral of f1 from 2 to 3 ~ 3.500000\n", + "integral of f2 from 2 to 3 = 6.666667\n", + "integral of f2 from 2 to 3 ~ 6.625000\n" + ] + } + ], + "source": [ + "fprintf('integral of f1 from 2 to 3 = %f',f2(3)-f2(2))\n", + "fprintf('integral of f1 from 2 to 3 ~ %f',(3-2)*f1(3/2+2/2))\n", + "\n", + "fprintf('integral of f2 from 2 to 3 = %f',f3(3)-f3(2))\n", + "fprintf('integral of f2 from 2 to 3 ~ %f',(3-2)*f2(3/2+2/2))\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This process is called **Gauss Quadrature**. Usually, the bounds are fixed at -1 and 1 instead of a and b\n", + "\n", + "$I=c_{0}f(x_{0})$\n", + "\n", + "and I is exact for polynomial of n=0, 1\n", + "\n", + "$\\int_{-1}^{1}1dx=b-a=c_{0}$\n", + "\n", + "$\\int_{-1}^{1}xdx=\\frac{1^2-(-1)^2}{2}=c_{0}x_{0}$\n", + "\n", + "so $c_{0}=2$ and $x_{0}=0$\n", + "\n", + "$I=\\int_{-1}^{1}f(x)dx \\approx 2f\\left(0\\right)$\n", + "\n", + "Now, integrals can be performed with a change of variable\n", + "\n", + "a=2\n", + "\n", + "b=3\n", + "\n", + "x= 2 to 3\n", + "\n", + "or $x_{d}=$ -1 to 1\n", + "\n", + "$x=a_{1}+a_{2}x_{d}$\n", + "\n", + "at $x_{d}=-1$, x=a\n", + "\n", + "at $x_{d}=1$, x=b\n", + "\n", + "so \n", + "\n", + "$x=\\frac{(b+a) +(b-a)x_{d}}{2}$\n", + "\n", + "$dx=\\frac{b-a}{2}dx_{d}$\n", + "\n", + "$\\int_{2}^{3}x+1dx=\\int_{-1}^{1}\\left(\\frac{(2+3) +(3-2)x_{d}}{2}\n", + "+1\\right)\n", + "\\frac{3-2}{2}dx_{d}$\n", + "\n", + "$\\int_{2}^{3}x+1dx=\\int_{-1}^{1}\\left(\\frac{5 +x_{d}}{2}\n", + "+1\\right)\n", + "\\frac{3-2}{2}dx_{d}$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$\\int_{2}^{3}x+1dx=\\int_{-1}^{1}\\left(\\frac{7}{4}+\\frac{1}{4}x_{d}\\right)dx_{d}=2\\frac{7}{4}=3.5$" + ] + }, + { + "cell_type": "code", + "execution_count": 157, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "function I=gauss_1pt(func,a,b)\n", + " % Gauss quadrature using single point\n", + " % exact for n<1 polynomials\n", + " c0=2;\n", + " xd=0;\n", + " dx=(b-a)/2;\n", + " x=(b+a)/2+(b-a)/2*xd;\n", + " I=func(x).*dx*c0;\n", + "end" + ] + }, + { + "cell_type": "code", + "execution_count": 159, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ans = 6.6250\r\n" + ] + } + ], + "source": [ + "gauss_1pt(f2,2,3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## General Gauss weights and points\n", + "\n", + "![Gauss quadrature table](gauss_weights.png)\n", + "\n", + "### If you need to evaluate an integral, to increase accuracy, increase number of Gauss points\n", + "\n", + "### Adaptive Quadrature\n", + "\n", + "Matlab/Octave built-in functions use two types of adaptive quadrature to increase accuracy of integrals of functions. \n", + "\n", + "1. `quad`: Simpson quadrature good for nonsmooth functions\n", + "\n", + "2. `quadl`: Lobatto quadrature good for smooth functions\n", + "\n", + "```matlab\n", + "q = quad(fun, a, b, tol, trace, p1, p2, …)\n", + "fun : function to be integrates\n", + "a, b: integration bounds\n", + "tol: desired absolute tolerance (default: 10-6)\n", + "trace: flag to display details or not\n", + "p1, p2, …: extra parameters for fun\n", + "quadl has the same arguments\n", + "```\n" + ] + }, + { + "cell_type": "code", + "execution_count": 164, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ans = 6.6667\n", + "ans = 6.6667\n", + "ans = 6.6667\n", + "f_c =\n", + "\n", + "@(x) cosh (x / 30) + exp (-10 * x) .* erf (x)\n", + "\n", + "ans = 2.0048\n", + "ans = 2.0048\n" + ] + } + ], + "source": [ + "% integral of quadratic\n", + "quad(f2,2,3)\n", + "quadl(f2,2,3)\n", + "f3(3)-f3(2)\n", + "f_c=@(x) cosh(x/30)+exp(-10*x).*erf(x)\n", + "\n", + "quad(f_c,1,3)\n", + "quadl(f_c,1,3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Numerical Differentiation\n", + "\n", + "Expanding the Taylor Series:\n", + "\n", + "$f(x_{i+1})=f(x_{i})+f'(x_{i})h+\\frac{f''(x_{i})}{2!}h^2+\\cdots$" + ] + }, + { + "cell_type": "code", + "execution_count": 165, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "Gnuplot\n", + "Produced by GNUPLOT 5.0 patchlevel 3 \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-4\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t4\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\n", + "\t\n", + "\t\tLow noise in sin wave\n", + "\t\n", + "\n", + "\n", + "\n", + "\tgnuplot_plot_1a\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\tgnuplot_plot_2a\n", + "\n", + "\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "x=linspace(-pi,pi);\n", + "y_smooth=sin(x);\n", + "y_noise =y_smooth+rand(size(x))*0.1-0.05;\n", + "plot(x,y_smooth,x,y_noise)\n", + "title('Low noise in sin wave')" + ] + }, + { + "cell_type": "code", + "execution_count": 166, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "Gnuplot\n", + "Produced by GNUPLOT 5.0 patchlevel 3 \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-4\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t4\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\n", + "\t\n", + "\t\tNoise Amplified with derivative\n", + "\t\n", + "\n", + "\n", + "\n", + "\tgnuplot_plot_1a\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\tgnuplot_plot_2a\n", + "\n", + "\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "% Central Difference derivative\n", + "\n", + "dy_smooth=zeros(size(x));\n", + "dy_smooth([1,end])=NaN;\n", + "dy_smooth(2:end-1)=(y_smooth(3:end)-y_smooth(1:end-2))/2/(x(2)-x(1));\n", + "\n", + "dy_noise=zeros(size(x));\n", + "dy_noise([1,end])=NaN;\n", + "dy_noise(2:end-1)=(y_noise(3:end)-y_noise(1:end-2))/2/(x(2)-x(1));\n", + "\n", + "plot(x,dy_smooth,x,dy_noise)\n", + "title('Noise Amplified with derivative')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Reduce noise\n", + "\n", + "Options:\n", + "\n", + "1. Fit a function and take derivative\n", + " \n", + " a. splines won't help much\n", + " \n", + " b. best fit curve (better)\n", + " \n", + "2. Smooth data (does not matter if you smooth before/after derivative)" + ] + }, + { + "cell_type": "code", + "execution_count": 168, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "Gnuplot\n", + "Produced by GNUPLOT 5.0 patchlevel 3 \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-4\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t4\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\tderiv of spline\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\tderiv of spline\n", + "\t\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\tno change\n", + "\n", + "\t\n", + "\t\tno change\n", + "\t\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "y_spline_i1=interp1(x,y_noise,x+0.1);\n", + "y_spline_in1=interp1(x,y_noise,x-0.1);\n", + "dy_spline=(y_spline_i1-y_spline_in1)/0.2;\n", + "plot(x,dy_spline,x,dy_noise)\n", + "legend('deriv of spline','no change')" + ] + }, + { + "cell_type": "code", + "execution_count": 169, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a = 1.0007\r\n" + ] + }, + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "Gnuplot\n", + "Produced by GNUPLOT 5.0 patchlevel 3 \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-4\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t4\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\n", + "\n", + "\tgnuplot_plot_1a\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\tgnuplot_plot_2a\n", + "\n", + "\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "Z=[sin(x')];\n", + "a=Z\\y_noise'\n", + "plot(x,a*sin(x),x,y_noise)" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "Gnuplot\n", + "Produced by GNUPLOT 5.0 patchlevel 3 \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-4\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t4\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\n", + "\n", + "\tgnuplot_plot_1a\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\tgnuplot_plot_2a\n", + "\n", + "\t \n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "plot(x,a*cos(x),x,dy_smooth,'o')" + ] + }, + { + "cell_type": "code", + "execution_count": 170, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ans =\n", + "\n", + " 1 100\n", + "\n" + ] + }, + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "Gnuplot\n", + "Produced by GNUPLOT 5.0 patchlevel 3 \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-4\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t4\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\n", + "\n", + "\tgnuplot_plot_1a\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\tgnuplot_plot_2a\n", + "\n", + "\t \n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "% Smooth data\n", + "N=10; % average data between 10 points (forward/backward)\n", + "y_data=[y_noise(N/2:-1:1) y_noise y_noise(end:-1:end-N/2+1)];\n", + "y_filter=y_data;\n", + "for i=6:length(x)\n", + " y_filter(i)=mean(y_data(i-5:i+5));\n", + "end\n", + "y_filter=y_filter(N/2:end-N/2-1);\n", + "size(y_filter)\n", + "plot(x,y_filter,x,y_noise,'.')" + ] + }, + { + "cell_type": "code", + "execution_count": 171, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "Gnuplot\n", + "Produced by GNUPLOT 5.0 patchlevel 3 \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\t\n", + "\t \n", + "\t \n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\t\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1.5\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-4\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t-1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t0\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t1\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t2\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t3\n", + "\t\n", + "\n", + "\n", + "\t\t\n", + "\t\t4\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\t\n", + "\n", + "\t\n", + "\t\tNoise Amplified with derivative\n", + "\t\n", + "\n", + "\n", + "\n", + "\tgnuplot_plot_1a\n", + "\n", + "\n", + "\n", + "\t\n", + "\t\n", + "\tgnuplot_plot_2a\n", + "\n", + "\t\n", + "\t\n", + "\tgnuplot_plot_3a\n", + "\n", + "\t \n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\t\n", + "\n", + "\t\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "" + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "dy_filter=zeros(size(x));\n", + "dy_filter([1,end])=NaN;\n", + "dy_filter(2:end-1)=(y_filter(3:end)-y_filter(1:end-2))/2/(x(2)-x(1));\n", + "\n", + "plot(x,dy_smooth,x,dy_filter,x,dy_noise,'.')\n", + "title('Noise Amplified with derivative')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Octave", + "language": "octave", + "name": "octave" + }, + "language_info": { + "file_extension": ".m", + "help_links": [ + { + "text": "MetaKernel Magics", + "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" + } + ], + "mimetype": "text/x-octave", + "name": "octave", + "version": "0.19.14" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/lecture_20/q1.png b/lecture_20/q1.png new file mode 100644 index 0000000..749476d Binary files /dev/null and b/lecture_20/q1.png differ diff --git a/lecture_20/q2.png b/lecture_20/q2.png new file mode 100644 index 0000000..d61cecd Binary files /dev/null and b/lecture_20/q2.png differ diff --git a/lecture_20/stainless_steel_psi.jpg.dat b/lecture_20/stainless_steel_psi.jpg.dat new file mode 100644 index 0000000..dfa2a4a --- /dev/null +++ b/lecture_20/stainless_steel_psi.jpg.dat @@ -0,0 +1,12 @@ +1.0208494318e-05 1.6556901722 +0.00241601032192 33.1999376148 +0.00420249682757 53.9506164087 +0.00603492155765 82.1777412288 +0.00844582763241 114.552704897 +0.00959768607462 122.017666367 +0.0207793901842 141.840010208 +0.0369377352739 161.610673548 +0.0574942399989 177.181817537 +0.0774314294019 181.959392878 +0.100609815751 174.241771174 +0.117644389936 156.618719826 diff --git a/lecture_20/steel_psi.jpg b/lecture_20/steel_psi.jpg new file mode 100644 index 0000000..5781642 Binary files /dev/null and b/lecture_20/steel_psi.jpg differ diff --git a/lecture_20/structural_steel_psi.jpg.dat b/lecture_20/structural_steel_psi.jpg.dat new file mode 100644 index 0000000..10c9ade --- /dev/null +++ b/lecture_20/structural_steel_psi.jpg.dat @@ -0,0 +1,13 @@ +1.0208494318e-05 1.6556901722 +0.00180179924712 23.2370851913 +0.00242111456908 34.0306538399 +0.00298938741945 36.5170602372 +0.00410551613155 38.1670081313 +0.0113042060414 39.7537909669 +0.026807506079 42.9158720819 +0.0450807109082 46.8799580317 +0.063896667352 49.1768692533 +0.0937667217264 50.5282186886 +0.134122601181 48.4475999405 +0.194912483429 42.0009357786 +0.224198952211 38.3737301413 diff --git a/lecture_20/trap_example.png b/lecture_20/trap_example.png new file mode 100644 index 0000000..facc398 Binary files /dev/null and b/lecture_20/trap_example.png differ