when i run...?the command page write Undefined function????

조회 수: 16 (최근 30일)
masoud mansouri
masoud mansouri 2015년 11월 25일
댓글: Star Strider 2015년 11월 25일
clear all;
clc
a=input('enter fun')
f=inline(a)
x(1)=input('enter first guess: ');
x(2)=input('enter second guess: ');
n=input('enter tolerance: ');
iteration=0;
i=2;
while (abs(x(i))>0.00001)
x(i+1)=x(i)-f(x(i))*(x(i)-x(i-1))/(f(x(i)-f(x(i-1))));
if (f(x(i+1))~=0)
i=i+1;
iteration=iteration+1
root=x(i)
break
else
root=x(i)
iteration=iteration
break
break
end
end
  댓글 수: 1
Stephen23
Stephen23 2015년 11월 25일
@masoud mansouri: can you please post the complete error message. This means all of the red text. It contains lots of useful information for us.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2015년 11월 25일
If you want to use the input function to input a string (that your inline call will use), you need to add 's' to the prompt:
a=input('enter fun', 's')
  댓글 수: 2
masoud mansouri
masoud mansouri 2015년 11월 25일
which means ('s')..could you write correct...?
Star Strider
Star Strider 2015년 11월 25일
I wrote the correct input call in my original Answer. Insert my ‘a’ assignment in place of yours and it should work correctly:
a=input('enter fun', 's')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scripts에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by