Question

I AM ADDING THE f FUNCTION GIVEN IN PROBLEM 9.1 ANY HELP IS APPRECIATED PLEASE THANK YOU

For N 0, 1,2, and 3, expand and calculate the value of where - n + 1 ann22

Problem 9.2 a) Write a for-loop in Matlab to calculate the f given in Problem 9.1 b) Step through the for-loop when N 3. Either display the values or provide a screen shot of the workspace for each iteration through the loop. Do your results make sense? Why or why not? c What is the value of f when N-100? Answer: c) 4.6302481157

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Editor CUsers Vaio\Documents MATLAB\prob19.m 唱唱 - 1.0 + 1.1 % 0, f=5 ; %assigning initilial value to f so as to start the loop h-input (\nEnter the value of N ); assigning user input value to variable N for n=1:N %starting loop from n-1 incrementing to N by 1 every time f-1+((n+1 ) / (n°2+2))*cos (pi*n); %defining the function in terms of n end fprintf(The value of f for N equal to %d is %0.10f\n,N, f) %printing the results on screen :: primey.m × prob19.m x Command Window で Command History New to MATLAB? Watch this Video, see Demos, or read Getting Started Enter the value of N 0 The value of f for N equal to 0 is 5.0000000000 Enter the value of N 1 The value of f for N equal to 1 is 4.3333333333 Enter the value of N 2 The value of f for N equal to 2 is 4.8333333333 Enter the value of N 3 The value of f for N equal to 3 is 4.4696969697 Enter the value of N 100 The value of f for N equal to 100 is 4.6302481157 兵>>cos(pi)=-1 and cos(2pi)=1. Since period of cos function is 2pi, for every odd Odd value of n, we'll get -1 and for every even value, we'll get +1. The value of (n+1)/(n^2+2) goes on increasing with every n value.

Initially, at n=1, the value will be subtracted from 5, so we have 4.333 as result.

At n=2, even though the value of cos is positive, it will be added to initially calculated value 4.333. So we see a small increment in it and the answer is 4.833

At, n=3, again some value will be subtracted, since cos(3pi)=-1. So the result will be a lesser value than 4.833 but not as low as 4.333 since some value was added to it in the previous step.

So the results do make sense.

CODE

f=5; %assigning initilial value to f so as to start the loop
N=input('\nEnter the value of N '); %assigning user input value to variable N
for n=1:N %starting loop from n=1 incrementing to N by 1 every time
f=f+((n+1)/(n^2+2))*cos(pi*n); %defining the function in terms of n
end
fprintf('The value of f for N equal to %d is %0.10f\n',N,f) %printing the results on screen

Add a comment
Know the answer?
Add Answer to:
I AM ADDING THE f FUNCTION GIVEN IN PROBLEM 9.1 ANY HELP IS APPRECIATED PLEASE THANK...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Please complete using matlab In this problem you will utilize a for loop to compute the...

    Please complete using matlab In this problem you will utilize a for loop to compute the an approximation of the value of using the Leibniz's formula for Pi. The formula uses a summation. Follow the instructions correctly and read the questions thoroughly. 1. Set up the initial number of iteration i to obtain six iterations. 2. The approximate value of it can be given by the following formula: Approximated = Enzo 2n+1 Where n is an integer starting at zero...

  • I am not goo?d at ana?lyze and solve the problem. Any help w?ith ex?plaination is? appreciated....

    I am not goo?d at ana?lyze and solve the problem. Any help w?ith ex?plaination is? appreciated. Thank you! Worksheet chapter 778 7. A big frozen tofu turkey in a box of total mass m-5kg is pushed up an incline (frictionless) a vertical distance of h-3m. . The block is traveling at the same speed (vi) at the bottom (1) of the incline as at the top (2). The speed at the top is v2-3m/s. At top the box slide a...

  • Hi I am confused by this problem. Any help would be greatly appreciated! Thanks! A large...

    Hi I am confused by this problem. Any help would be greatly appreciated! Thanks! A large building shapped like a box is 45 m high with a face that is 90 m wide. A strong wind blows directly at the face of the building, exerting a pressure of 110 N/m at the ground and increasing with height according to P(y) 110 + 2y , where y is the height above the ground. Calculate the total force on the building, which...

  • Problem 5 xx The Taylor series expansion for sin(x) is sin(x) = x -H + E-E+...

    Problem 5 xx The Taylor series expansion for sin(x) is sin(x) = x -H + E-E+ = o E- (-1) . 2n +1 no (2n+1)! !57 where x is in radians. Write a MATLAB program that determines sin(x) using the Taylor series expansion. The program asks the user to type a value for an angle in degrees. Then the program uses a while loop for adding the terms of the Taylor series. If an n is the nth term in...

  • MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts...

    MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts in order to get full credit. Help me out, thank you f LAB SECTION NAME HW6P3 (30 points) following are infinite series representations of the function, un pra i a script file HW6P3 that determines the value of the function from the sum of the series for a given value of x. The program (1 pt) must prompt the user to enter a value...

  • Using the random dumber library in c++ please help me out with this problem. I am...

    Using the random dumber library in c++ please help me out with this problem. I am suppose to simulate at the bat using the information given. Out Walk 9.7% Single 22.0% Double 6.1% Triple 2.5% Home Run 1.7% 58.0% Based on the above percentages, write a program to simulate Casey stepping up to the plate 1000 times and count and display the number of outs, walks, singles and so on. Then calculate and display his batting average: number of hits...

  • Need some guidance with the following problems as I am new to Java programming. Any assistance...

    Need some guidance with the following problems as I am new to Java programming. Any assistance is greatly appreciated. Thanks Using printf and specifiers for all print instructions: 1.            Code the following: a.            10% is stored in a variable called discount when the customer is a student; otherwise, it stores 0%. Code this if … else control structure using the conditional operator (ternary operator). The variables discount and student have already been declared. Assume student is a boolean variable. b.           ...

  • I am failing one of the tests cases for the trimArray function. The test that my...

    I am failing one of the tests cases for the trimArray function. The test that my function is failing is testing that when you get a toTrim array of  " ", it should return "" (an array of no characters). How do I incorporate that functionality into the function and where will it go in the C++ code? Here's my function: // The function trimArray() is given a pointer to a character array that // is NULL terminated called toTrim. This...

  • wnloads/HW5 pdf Create a MATLAB code to calculate function f (z) = ei8r at any given...

    wnloads/HW5 pdf Create a MATLAB code to calculate function f (z) = ei8r at any given point using Taylor series. Write a script file called myTaylor.m and a function file called myFact.m to do the following: (a) The function myFact.m should return the factorial of a number when sent the number. In the script file: i. Set the starting point as r0-1 and fo = f(d)-6.049647 ii. Ask the user to enter his/her desired point and store it in x1...

  • This is a matlab HW that I need the code for, if someone could help me figure this out it would b...

    This is a matlab HW that I need the code for, if someone could help me figure this out it would be appreciated. The value of t can be estimated from the following equation: in your script file, estimate the value of π for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT