Menu

(Solved) : Code Run Dont Know Please Help Code Even Change Duplicate Name Still Run Thank Much Q43957354 . . .

Thecode can not be run, and i dont know why, please help me with thiscode! Even I change the duplicate name it still can not be run.Thank you so much
NAVIGATE EDIT BREAKPOINTS Yunbin Hao Desktop ▸ Numerial Method Assignment Assignment 1 Editor - C:UsersYunbin HaoDesktopNuN 111 GATE EDIT BREAKPOINTS RUN unbin Hao Desktop ▸ Numerial Method Assignment Assignment 1 Editor - C:UsersYunbin HaoDeskNAVIGATE EDIT BREAKPOINTS Yunbin Hao Desktop ▸ Numerial Method Assignment Assignment 1 Editor – C:UsersYunbin HaoDesktopNumerial Method Assignment Assignment 1secant.m secant.m X + Implement secant method X = 0; y 1: LI fun = @(x) X-2*exp(-x): answer – secantm (fun,x,y); Q function p = secantm (f,x,y) i = 2; x (2)=y; El for i = 2:10 x(i+1) = x(i)-f(x(i))*(x(x))/(f(x(i-1))-f(x(i))); err = abs((x(i+1)-x(i))/x(i+1)); if (err <= le-4) break; end end disp ( [Number of Iterations=’, num2str (1) 1); P = x(i); end Command Window >> secant Array indices must be positive integers or logical values. Error in secant>secantm (line 10) x(1+1) = x (1)-f(x(i))*(x (x))/(f(x(1-1))-f(x(1))); Error in secant (line 5) answer = secantm (fun, x,y); N 111 GATE EDIT BREAKPOINTS RUN unbin Hao Desktop ▸ Numerial Method Assignment Assignment 1 Editor – C:UsersYunbin HaoDesktopNumerial Method Assignment Assignment 1secant secant. m x + $Implement secant method x = 0; y = 1; fun = @ (x) x-2*exp(-x): answer = secant (fun,X,Y): Çfunction p = secant (f,x,y) i = 2; x(2)=y; for i = 2:10 x(i+1) – x(1)-f(x(i))*(x(x))/(f(x(i-1))-f(x(1))); err = abs((x(i+1) -x(i))/x(i+1)); if (err <= le-4) break; end end disp([‘Number of Iterations=’, num2str (1)]); p = x(1); end con HEHE Coo Command Window >> secant Error: File: secant.m Line: 6 Column Tunction with duplicate name secant” cannot be defined. x > script Show transcribed image text NAVIGATE EDIT BREAKPOINTS Yunbin Hao Desktop ▸ Numerial Method Assignment Assignment 1 Editor – C:UsersYunbin HaoDesktopNumerial Method Assignment Assignment 1secant.m secant.m X + Implement secant method X = 0; y 1: LI fun = @(x) X-2*exp(-x): answer – secantm (fun,x,y); Q function p = secantm (f,x,y) i = 2; x (2)=y; El for i = 2:10 x(i+1) = x(i)-f(x(i))*(x(x))/(f(x(i-1))-f(x(i))); err = abs((x(i+1)-x(i))/x(i+1)); if (err > secant Array indices must be positive integers or logical values. Error in secant>secantm (line 10) x(1+1) = x (1)-f(x(i))*(x (x))/(f(x(1-1))-f(x(1))); Error in secant (line 5) answer = secantm (fun, x,y);
N 111 GATE EDIT BREAKPOINTS RUN unbin Hao Desktop ▸ Numerial Method Assignment Assignment 1 Editor – C:UsersYunbin HaoDesktopNumerial Method Assignment Assignment 1secant secant. m x + $Implement secant method x = 0; y = 1; fun = @ (x) x-2*exp(-x): answer = secant (fun,X,Y): Çfunction p = secant (f,x,y) i = 2; x(2)=y; for i = 2:10 x(i+1) – x(1)-f(x(i))*(x(x))/(f(x(i-1))-f(x(1))); err = abs((x(i+1) -x(i))/x(i+1)); if (err > secant Error: File: secant.m Line: 6 Column Tunction with duplicate name secant” cannot be defined. x > script

Expert Answer


Answer to The code can not be run, and i dont know why, please help me with this code! Even I change the duplicate name it still c…

OR