clear all clc obtain an input from the user m input 39 please enter a value for m 39 5187641

clear all;
clc;

% Obtain an input from the user
m = input('Please enter a value for m: ');
% Enforce the input must be an positive integer
while (m
fprintf('ERROR: Invalid input. Please try again.n');
m = input('Please re-enter a value for m: ');
end

% Assign the sepecific value for each of t
t(1) = sqrt(m);
t(2) = sqrt(m-sqrt(m));
% Assign the difference between two successive terms of t
tol = 1e-12;
while abs(t(m) – t(m-1)) > 1e-12
if mod(m,2) ~= 0
t(m) = sqrt(m-sqrt(m + t(m-1)));
else t(m) = sqrt(m-sqrt(m + t(m-2)));
end
fprintf('Value of t %20.6fn', t(m));
end

Everytime I run this code, an error shows ” Index exceeds matrix dimensions”. Could anyone help me with this?

Thank you.

"Get 15% discount on your first 3 orders with us"
Use the following coupon
FIRST15

Order Now