Path: news.mathworks.com!not-for-mail
From: "Ahmad " <climber65@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: M-File - How to input ?
Date: Tue, 3 Nov 2009 18:13:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 34
Message-ID: <hcprre$sfp$1@fred.mathworks.com>
Reply-To: "Ahmad " <climber65@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257271982 29177 172.30.248.35 (3 Nov 2009 18:13:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 3 Nov 2009 18:13:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2075042
Xref: news.mathworks.com comp.soft-sys.matlab:582117


If I want to input a function without a gui then how can I do it so that the M-file is a exe and still asks user for input and executes code line-by-line and then asks for input in whichever line it is required?

In the following I want to input g,a,b, and tol from user. How can I get this done?

syms x
g=?
dg=diff(g,x);
f=sym2poly(g);
df=sym2poly(dg);

a=?
b=?
tol=?
itr=2;
itrr=50;

for i=1:itr
p=(a+b)/2;
if(polyval(f,a)*polyval(f,p)<0)
b=p;
else
a=p;
end
end
s=p;

for j=1:itrr
s1=s-polyval(f,s)/polyval(df,s)
if(polyval(f,s)==0|[abs(s-s1)/s]<tol)
break
else
s=s1
end
end