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:
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:
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc433072d-a9c7-4220-8af9-1592d94e2de8%2F6d472152-efae-473c-8266-5c167137f419%2Fqrxd5xn_processed.png&w=3840&q=75)
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:](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc433072d-a9c7-4220-8af9-1592d94e2de8%2F6d472152-efae-473c-8266-5c167137f419%2Fbldy9bc_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![New Perspectives on HTML5, CSS3, and JavaScript](https://www.bartleby.com/isbn_cover_images/9781305503922/9781305503922_smallCoverImage.gif)
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![New Perspectives on HTML5, CSS3, and JavaScript](https://www.bartleby.com/isbn_cover_images/9781305503922/9781305503922_smallCoverImage.gif)
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
![Microsoft Visual C#](https://www.bartleby.com/isbn_cover_images/9781337102100/9781337102100_smallCoverImage.gif)
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage