What is the matlab code for the following: With x_1 = 23, x_2 = 66, and x_n = 3x_(n−1) + 5x_(n−2) mod(100), n ≥ 3 we will call the sequence un = x_n/100, n ≥ 1, the text’s random number sequence. Find its first 14 values.
function u = modulus (x1,x2)
x = zeros(1,14);
x(1) = x1 ;
x(2) = x2 ;
for i = 3 : 14
x (i) = mod ((3 * x(i-1) + 5*x(i-2)) , 100)
;
end
for i = 1 : 14
u(i) = x(i)/100;
end
// this function takes x1 and x2 as input
modulus(23,66)
ans =
Columns 1 through 13
0.2300 0.6600 0.1300 0.6900 0.7200 0.6100 0.4300 0.3400 0.1700 0.2100 0.4800 0.4900 0.8700
Column 14
0.0600
Please rate
Get Answers For Free
Most questions answered within 1 hours.