Question: clear all; clc; % Obtain an input from the user m = input('Please enter a value for m: '); % Enforce the input must be

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 < 1 || mod(m,1) ~= 0) fprintf('ERROR: Invalid input. Please try again. '); 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.6f ', t(m)); end

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

Thank you.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!