Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions