- Initialise a counter to zero before the loop and update it within the loop,
- Use the counter value at each iteration to subscript ‘Outputs’ after it is computed and assign the current value of ‘est’ to it,
- For the 4 decimal place precision, I would use the round function with appropriate multiplications and divisions to get the correct format, although you could also use sprintf, depending on what functions you are allowed to use,
- Then the plot of ‘Outputs’ is straightforward.
How do I do this question?
1 view (last 30 days)
Show older comments
I have to finish this and don't know how to exactly do it: The algorithm is very simple. We want to find x= ∜N
Make an initial guess for x: Est. See how close you are: Error = abs(Est4 – N) If the Error is too big, update the estimate as follows:
Est=Est- (Est^4-N)/(4*Est^3 )
Recalculate the Error using the new estimate Repeat until the value of Error is small enough.
Write a MATLAB script that does the following:
Prompts the user for the Number, N, to find the 4th root of Sets the initial guess to 1 Uses the algorithm describe above to repeatedly update the estimate until the value of Error does not exceed 0.0001. Saves all the values for Est in a vector Outputs the following:
The final value of the estimate for the 4th root of N. Use 4 decimal places. A count of how many iterations were required through the loop A plot with all the values for Est4
This is what I have so far:
N = input ('Enter the number: ');
est = 1;
error = abs(est.^4-N);
while error > .0001;
est = (est-((est.^4-N)/(4*est.^3)));
error = abs(est.^4-N);
end
0 Comments
Accepted Answer
Star Strider
on 31 Oct 2014
Your code works as far as it goes.
You still need to:
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!