Question
CODE USED HW6P3.m QUESTION a) Modify your program HW6P3.m to HW6P4a.m that uses a while loop which terminates once 20 instead of the for loop.
CODE USED
HW6P3.m
QUESTION
a) Modify your program HW6P3.m to HW6P4a.m that uses a while loop which terminates once 20 instead of the for loop.
b) Modify your program HW6P4a.m to HW6P4b.m that works not only for scalars but also for any vector or 2D matrix. You will need to nest your while loop for HW6P4a.m inside 2 other for loops, one for each matrix dimension. One of the 2 for loops will be nested in the other. Your program must determine the dimensions m and n of the input array and preallocate a matrix Root3(m,n) of the same size using the zeros function as in HW6P1. For every value of the input matrix P(i,j), the program must determine its cubic root as before and then save it in Root3(i,j) such that at the end of the program Root3 will be similar to P.^(1/3).The output must be displayed as:
The Cubic Root of the Input Matrix is: ------- ------- Use the disp function to display the text and the values in Root3.
Test your program on the following arrays:
1) B = [ 1 8 27 64 125] 2) E=[1 8 27 64 125; 8 64 216 512 1000]
3) F = [1:5; 6:10; 11:15]
File Edit Text Go Cell Tools Debug Desktop Window Help Stack: Base -1.0 + 1.1 0, clear P-input ('Enter the number whose cube root is to be found out In %formula for Halley's method xipl=xi"(xi"3+2 * P)/(2*xi"3+P) %Formula for error E-abs( (xip1-X1)/X1) xi-P: % initial guess N=20; %Maximum number of passes for R-1:N 10 E-abs ((xipl-xi)/xi): if EStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started