Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

P=input('Calculate cube root for: ') xi=P; xip1=0; %if true flag=true; while flag xip1=xi*((xi^3+2*P)/(2*xi^3+P)); if (abs(xip1-xi)/xi) 20 instead of the for loop. You must notice that

P=input('Calculate cube root for: ') xi=P; xip1=0; %if true flag=true; while flag xip1=xi*((xi^3+2*P)/(2*xi^3+P)); if (abs(xip1-xi)/xi)<.00001 %if false flag=false; end xi=xip1; end %display the root disp('cubic root of number: ') disp(xip1)

Modify your program that uses a while loop which terminates once < 10^10 or > 20 instead of the for loop. You must notice that the while loop in this problem does not need a break command.

Modify your program that works not only for scalars but also for any vector or 2D matrix. You will need to nest your while loop 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. 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]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5-3 What are the current trends in computer hardware platforms?

Answered: 1 week ago

Question

=+8. Why is productivity important?

Answered: 1 week ago

Question

=+ 9. What is inflation and what causes it?

Answered: 1 week ago