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


"ade77 " <ade100a@gmail.com> wrote in message <hcpsg2$aqj$1@fred.mathworks.com>...
> 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

thx