Please solve the following equation using MATLAB , i\'m having a hard time under
ID: 2291610 • Letter: P
Question
Please solve the following equation using MATLAB , i'm having a hard time undersanding it.(Please Paste the codes bellow all steps) ,I have to take my final exam in the next 48 hours.
Problem 2 Consider the causal non-linear discrete-time system characterized by the following difference equation: If we use as input x[n] to this system (algorithm) a step function of amplitude A (i.e. x[n]-A u[n]), then y[n] will converge after several iterations to the square root of A Write a MATLAB program that implements the above recursion to compute the square root of 8 49, 16 and 3. How many iterations does it take to converge to the true value starting at y-1]-0.2?Explanation / Answer
% MATLAB program to implement the given iteration to compute the square root of 81,49,16 and 3.
function [sqrtX num_iteration] = sqrtX1(X,y_1)
yprev = y_1;%y[-1]
num_iteration = 1;
while 1 == 1
ynext = 0.5*((yprev)+(X/yprev));
if abs(yprev-ynext)<10^-4
sqrtX = ynext;
break;
else
yprev = ynext;
num_iteration = num_iteration+1;
end
end
end
Result displayed on command window:
>> sqrtX1(16,1)
ans =
4.0000
>> sqrtX1(4,1)
ans =
2.0000
>> sqrtX1(5,1)
ans =
2.2361
>> sqrtX1(3,1)
ans =
1.7321
>> [sqrtX, num_iteration] = sqrtX1(3,0.5)
sqrtX =
1.7321
num_iteration =
6