where dit is the i'th term in the intf array. In other words, intf (1) will be equal to £ (1) *dt, intf (2) will be equal to (£ (1) +£ (2) ) *dt, intf (3) will be equal to (£ (1) +£ (2) +£ (3)) *dt, and so on. Here is an example of what you should get with f = t² and dt = 0.001 >>>dt 0.001; >>t [0:10000] *dt; >>> £= t.^2; >>>[df,intf] = dfint (f,dt); I have uploaded to HuskyCT a "dfint.mat." file that contains the expected df and int.f values. Make sure you download this to your MATLAB default directory. You can verify your results as follows: >>load('dfint.mat'); >> sum (abs (df-dfexpected) <0.000001)-10001 ans logical 1 >> sum (abs (int.f-int fexpected) <0.000001)=10001 ans logical 1 Depending on how you do the calculations, you may get some rounding errors that may cause your df and int£ arrays to not exactly equal the expected values from the dfint.mat file. The code above will check that your answer is within 0.000001 of the expected values. If not, you will get 0 as an answer, and you will need to fix your code. Objective Your task is to write two functions that can calculate the derivative and integral of an unknown function. Unknown functions typically arise because the function values come from data collected from a signal. In such cases, since you don't have a mathematical equation describing the function, you can't use the techniques you learned in Calc 1 and 2 to do the derivative or the integral. Therefore, you have to fall back on the definitions of a derivative and an integral. To calculate the derivative, let's revisit the definition of the derivative: df(t) = lim dt AL-D f(t+At)f(t) At Let's assume that you set dit to a very small value, so that you can eliminate the limit. Therefore, df (t) = f(t + At) - ƒ (t) = f (t) − f(t − At) dt Δε Δε The second form of the derivative equation shows that your code can calculate the derivative by comparing the current value of the function (or signal) with the last value from the previous time point and dividing by At. The integral term is the area under the function curve. From calculus, you should remember that you can approximate the integral by summing up all the signal points and multiplying by At. That means as you go through time, you can keep a running sum of the total signal values which represents the integral up to that point. Writing the code Here is the template for the function that you will need to complete: function [df,intf] = dfint (f, dt) end df zeros(1, length (f)); intf zeros(1, length (f)); & iterate over the f array and for each time value, $ $ 1. calculate the derivative value by taking the current value of f, subtracting the previous value and dividing by dt 2. Calculate the integral by keeping a running sum of the f values and multiplying by dt. The function takes in two arguments corresponding to an array containing the signal data points and a dt: value. If we assume that the data points are due to sampling a signal, the dt. value is corresponds to the sampling period. The result of the derivative calculation will be put into the df array and the result of the integral calculation will be put into the intf array. Both arrays should have the same number of values as the farray. You can rewrite the derivative equation in array terms as follows: df(t)_(4)-1 (4-1) dt = Δε where /(4) is the i'th term in the farray and is the i'th term in the df array. You can assume dt that /(4)=0. Thus, df (1) will be equal to (f(1)-0)/dt, df (2) will be equal to (f(2)- f(1))/dt, intf(3) will be equal to (£ (3) -£ (2))/dt, and so on. Likewise, the integral can be written as:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
where dit is the i'th term in the intf array. In other words, intf (1) will be equal to £ (1) *dt,
intf (2) will be equal to (£ (1) +£ (2) ) *dt, intf (3) will be equal to (£ (1) +£ (2) +£ (3)) *dt,
and so on.
Here is an example of what you should get with f = t² and dt = 0.001
>>>dt
0.001;
>>t [0:10000] *dt;
>>> £= t.^2;
>>>[df,intf] = dfint (f,dt);
I have uploaded to HuskyCT a "dfint.mat." file that contains the expected df and int.f values. Make
sure you download this to your MATLAB default directory. You can verify your results as follows:
>>load('dfint.mat');
>> sum (abs (df-dfexpected) <0.000001)-10001
ans
logical
1
>> sum (abs (int.f-int fexpected) <0.000001)=10001
ans
logical
1
Depending on how you do the calculations, you may get some rounding errors that may cause
your df and int£ arrays to not exactly equal the expected values from the dfint.mat file.
The code above will check that your answer is within 0.000001 of the expected values. If not,
you will get 0 as an answer, and you will need to fix your code.
Transcribed Image Text:where dit is the i'th term in the intf array. In other words, intf (1) will be equal to £ (1) *dt, intf (2) will be equal to (£ (1) +£ (2) ) *dt, intf (3) will be equal to (£ (1) +£ (2) +£ (3)) *dt, and so on. Here is an example of what you should get with f = t² and dt = 0.001 >>>dt 0.001; >>t [0:10000] *dt; >>> £= t.^2; >>>[df,intf] = dfint (f,dt); I have uploaded to HuskyCT a "dfint.mat." file that contains the expected df and int.f values. Make sure you download this to your MATLAB default directory. You can verify your results as follows: >>load('dfint.mat'); >> sum (abs (df-dfexpected) <0.000001)-10001 ans logical 1 >> sum (abs (int.f-int fexpected) <0.000001)=10001 ans logical 1 Depending on how you do the calculations, you may get some rounding errors that may cause your df and int£ arrays to not exactly equal the expected values from the dfint.mat file. The code above will check that your answer is within 0.000001 of the expected values. If not, you will get 0 as an answer, and you will need to fix your code.
Objective
Your task is to write two functions that can calculate the derivative and integral of an unknown function.
Unknown functions typically arise because the function values come from data collected from a signal. In
such cases, since you don't have a mathematical equation describing the function, you can't use the
techniques you learned in Calc 1 and 2 to do the derivative or the integral. Therefore, you have to fall
back on the definitions of a derivative and an integral.
To calculate the derivative, let's revisit the definition of the derivative:
df(t)
= lim
dt AL-D
f(t+At)f(t)
At
Let's assume that you set dit to a very small value, so that you can eliminate the limit. Therefore,
df (t) = f(t + At) - ƒ (t) = f (t) − f(t − At)
dt
Δε
Δε
The second form of the derivative equation shows that your code can calculate the derivative by
comparing the current value of the function (or signal) with the last value from the previous time point
and dividing by At.
The integral term is the area under the function curve. From calculus, you should remember that you can
approximate the integral by summing up all the signal points and multiplying by At. That means as you
go through time, you can keep a running sum of the total signal values which represents the integral up
to that point.
Writing the code
Here is the template for the function that you will need to complete:
function [df,intf] = dfint (f, dt)
end
df zeros(1, length (f));
intf zeros(1, length (f));
& iterate over the f array and for each time value,
$
$
1. calculate the derivative value by taking the current value
of f, subtracting the previous value and dividing by dt
2. Calculate the integral by keeping a running sum of the f
values and multiplying by dt.
The function takes in two arguments corresponding to an array containing the signal data points and a
dt: value. If we assume that the data points are due to sampling a signal, the dt. value is corresponds to
the sampling period. The result of the derivative calculation will be put into the df array and the result
of the integral calculation will be put into the intf array. Both arrays should have the same number of
values as the farray.
You can rewrite the derivative equation in array terms as follows:
df(t)_(4)-1 (4-1)
dt
=
Δε
where /(4) is the i'th term in the farray and is the i'th term in the df array. You can assume
dt
that /(4)=0. Thus, df (1) will be equal to (f(1)-0)/dt, df (2) will be equal to (f(2)-
f(1))/dt, intf(3) will be equal to (£ (3) -£ (2))/dt, and so on.
Likewise, the integral can be written as:
Transcribed Image Text:Objective Your task is to write two functions that can calculate the derivative and integral of an unknown function. Unknown functions typically arise because the function values come from data collected from a signal. In such cases, since you don't have a mathematical equation describing the function, you can't use the techniques you learned in Calc 1 and 2 to do the derivative or the integral. Therefore, you have to fall back on the definitions of a derivative and an integral. To calculate the derivative, let's revisit the definition of the derivative: df(t) = lim dt AL-D f(t+At)f(t) At Let's assume that you set dit to a very small value, so that you can eliminate the limit. Therefore, df (t) = f(t + At) - ƒ (t) = f (t) − f(t − At) dt Δε Δε The second form of the derivative equation shows that your code can calculate the derivative by comparing the current value of the function (or signal) with the last value from the previous time point and dividing by At. The integral term is the area under the function curve. From calculus, you should remember that you can approximate the integral by summing up all the signal points and multiplying by At. That means as you go through time, you can keep a running sum of the total signal values which represents the integral up to that point. Writing the code Here is the template for the function that you will need to complete: function [df,intf] = dfint (f, dt) end df zeros(1, length (f)); intf zeros(1, length (f)); & iterate over the f array and for each time value, $ $ 1. calculate the derivative value by taking the current value of f, subtracting the previous value and dividing by dt 2. Calculate the integral by keeping a running sum of the f values and multiplying by dt. The function takes in two arguments corresponding to an array containing the signal data points and a dt: value. If we assume that the data points are due to sampling a signal, the dt. value is corresponds to the sampling period. The result of the derivative calculation will be put into the df array and the result of the integral calculation will be put into the intf array. Both arrays should have the same number of values as the farray. You can rewrite the derivative equation in array terms as follows: df(t)_(4)-1 (4-1) dt = Δε where /(4) is the i'th term in the farray and is the i'th term in the df array. You can assume dt that /(4)=0. Thus, df (1) will be equal to (f(1)-0)/dt, df (2) will be equal to (f(2)- f(1))/dt, intf(3) will be equal to (£ (3) -£ (2))/dt, and so on. Likewise, the integral can be written as:
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education