Share
Explore BrainMass

Matlab Programming

Develop a program (M-File) called 'integrate' that will perform a first-order numerical approximation, yi(t), of the running integral with respect to time of an array of experimental data y(t). The M-File must also perform another first order approximation, yi2(t), of the first integral resulting in a double integration of the experimental data. A plot of y(t) must be generated on a single sheet of paper. On a second sheet of paper the functions yi(t) and yi2(t) must be plotted as two separate subplots, with the top half of the sheet containing the plot of yi(t) and the bottom half containing the plot of yi2(t). The inputs and outputs will be:

Inputs: A row vector with an arbitrary number of data points and the time step delta.

Outputs: A plot of the function y(t), a plot of the integral of the function yi(t), and a plot of the double integral yi2(t). To be plotted separately.

Using M-File:

(a) Run M-file and when asked for the input row vector enter 0:100, thich will generate a row vector with 100 entries. Use a delta of 0.01.

(b) Run M-file and when asked for the input row vector enter randn(1,101), which will generate a random vector with 100 entries. Use a delta of 0.01.

*Multiple graphs can be generated from the same M-File using the command 'figure' before each plot command.

Attachments

Solution Preview

Here is the code for the required program. I've included lots of commentaries because I believe that it can sometimes be quite difficult to understand a code written by another person. I hope this is clear enough.
clear all %
close all %Standard lines to clear variables and close graph windows

%Ask for data vector. For example: 0:100, or randn(1,101).
%Store it in x
x=input('Data ...

Solution Summary

This shows how to develop a Matlab program to perform first-order numerical approximation of a running integral.

$2.19