Path: news.mathworks.com!not-for-mail
From: "ade77 " <ade100a@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: M-File - How to input ?
Date: Tue, 3 Nov 2009 18:24:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 40
Message-ID: <hcpsg2$aqj$1@fred.mathworks.com>
References: <hcprre$sfp$1@fred.mathworks.com>
Reply-To: "ade77 " <ade100a@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257272642 11091 172.30.248.38 (3 Nov 2009 18:24:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 3 Nov 2009 18:24:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1059495
Xref: news.mathworks.com comp.soft-sys.matlab:582121


use inputdlg
for example;
g = inputdlg('enter the value of g'), will display a dialog box, where the user can enter the value of g.
type doc inputdlg at the command prompt to get more options on this function

"Ahmad " <climber65@gmail.com> wrote in message <hcprre$sfp$1@fred.mathworks.com>...
> 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