[Solved] Using Matlab Find Loop Derivatives Equation Used Earlier However Get Loop Function Work Q37215612
I am using Matlab to find a loop of derivatives for anequation I used earlier. I however can not get this loop functionto work.


5/viewContent/3799701/View / 202 Matlab Project_ll ????????? %Call your projectileMotion function and pass in V and It. If l typed V(1) what value would i %get? What if I typed it13? end 3. Create another user-defined function called derivative that when given two vectors (x and f(x) it returns the derivative of the function f(x) as shown in Equation 2 [dfx] derivative (x, fx) Recall from our Excel derivative HW (it might be helpful to look back at it) that the derivative of a function can be -77tf(xi+1 )2 where i-0, 1, 2, That is, the approximate derivative is simply the change in fx divided by the change in x where, since it is approximated by (n-1 ) approximate, we don’t need to use the limit. We simply need to make our change in x reasonably small. What does this mean for our Matlab code? It means we need to incorporate equation 3 into a loop that performs the following operation dfx(1)-fx2-fx(1)x2-x(1) dfx (2)-fx3-fx(2)x3-x(2) djx(3)-x4-fx(3)x4-x(3) does this mean for our Matlab code? It means we need to incorporate equation 3 into a loop that performs the following operation: dfx(1)-fx2-fx(1)x2-x(1) dfx(2)-fx3-fx(2)x3-x(2) dfx (3)-fx4-fx(3)x4-x(3) continue to length of fx-1 Keep in mind that your numeric derivative (Af(x)/Ax) will have one less element in it than your original x, so when plotting you might use a command similar to the following: plot(x(1 end 1), dfx). This uses a handy little trick in MATLAB that enables you to index the last element in a list or matrix by just indexing end The plot command above indexes the end of the list minus one, or all but the last element in the list, therefore, if you go to plot the dfx versus x, they will have the same number of elements and you will not get an error. Recall that the length command in MATLAB provides the number of elements in a vector function [dfx] – derivative( x, fx ) %Hint: If you were doing this by hand, how would you get the derivative of fx at the point where x something like: dfx(1)- (fx(2)-fx(1))/(x(2)-x(1)); %How about at x 2? And so on? dfx(2)- (fx(3)-fx(2))/(x(3)-x(2)): dfx(3) (fx(4)-fx(3))/(x(4)-x(3)); dfx(4) (fx(5)-fx(4))/(x(5)-x(4)): 1 ? You %would probably do 1:length(Tx)-1 times. %)” % l see a pattern. Now all you need to do is incorporate this into a forloop that loops through 4 Using the functions created in Problems 1 and 3 above, plot the vertical distance, vertical velocity, and vertical within your code on blem, use 0op/4 and vo 400 m/s C acceleration as functions of time For this Show transcribed image text 5/viewContent/3799701/View / 202 Matlab Project_ll ????????? %Call your projectileMotion function and pass in V and It. If l typed V(1) what value would i %get? What if I typed it13? end 3. Create another user-defined function called derivative that when given two vectors (x and f(x) it returns the derivative of the function f(x) as shown in Equation 2 [dfx] derivative (x, fx) Recall from our Excel derivative HW (it might be helpful to look back at it) that the derivative of a function can be -77tf(xi+1 )2 where i-0, 1, 2, That is, the approximate derivative is simply the change in fx divided by the change in x where, since it is approximated by (n-1 ) approximate, we don’t need to use the limit. We simply need to make our change in x reasonably small. What does this mean for our Matlab code? It means we need to incorporate equation 3 into a loop that performs the following operation dfx(1)-fx2-fx(1)x2-x(1) dfx (2)-fx3-fx(2)x3-x(2) djx(3)-x4-fx(3)x4-x(3)
does this mean for our Matlab code? It means we need to incorporate equation 3 into a loop that performs the following operation: dfx(1)-fx2-fx(1)x2-x(1) dfx(2)-fx3-fx(2)x3-x(2) dfx (3)-fx4-fx(3)x4-x(3) continue to length of fx-1 Keep in mind that your numeric derivative (Af(x)/Ax) will have one less element in it than your original x, so when plotting you might use a command similar to the following: plot(x(1 end 1), dfx). This uses a handy little trick in MATLAB that enables you to index the last element in a list or matrix by just indexing end The plot command above indexes the end of the list minus one, or all but the last element in the list, therefore, if you go to plot the dfx versus x, they will have the same number of elements and you will not get an error. Recall that the length command in MATLAB provides the number of elements in a vector function [dfx] – derivative( x, fx ) %Hint: If you were doing this by hand, how would you get the derivative of fx at the point where x something like: dfx(1)- (fx(2)-fx(1))/(x(2)-x(1)); %How about at x 2? And so on? dfx(2)- (fx(3)-fx(2))/(x(3)-x(2)): dfx(3) (fx(4)-fx(3))/(x(4)-x(3)); dfx(4) (fx(5)-fx(4))/(x(5)-x(4)): 1 ? You %would probably do 1:length(Tx)-1 times. %)” % l see a pattern. Now all you need to do is incorporate this into a forloop that loops through 4 Using the functions created in Problems 1 and 3 above, plot the vertical distance, vertical velocity, and vertical within your code on blem, use 0op/4 and vo 400 m/s C acceleration as functions of time For this
Expert Answer
Answer to I am using Matlab to find a loop of derivatives for an equation I used earlier. I however can not get this loop function… . . .
Related