Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to generate data by Matlab?
Date: Wed, 16 Jan 2008 01:06:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 49
Message-ID: <fmjl9s$4g8$1@fred.mathworks.com>
References: <ffqtva$bpk$1@fred.mathworks.com> <ffrcug$qpj$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1200445564 4616 172.30.248.37 (16 Jan 2008 01:06:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 16 Jan 2008 01:06:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1161857
Xref: news.mathworks.com comp.soft-sys.matlab:445891



"Dan Haeg" <haegd@msoe.edu> wrote in message 
<ffrcug$qpj$1@fred.mathworks.com>...
> "Hero Lee" <hero@mathworks.com> wrote in message
> <ffqtva$bpk$1@fred.mathworks.com>...
> > Dear Sir or Madam,
> > 
> > I'm just a beginner on Matlab, and would like to 
generate
> > data from a function by Matlab.
> > 
> > The Function is:
> > Y=f(x1,x2)=[1+(x1)^-2+(x2)^-1.5]^2
> > where x1 is belonged to [1,5],
> >       x2 is belonged to [1,5].
> > 
> > How can I do if I want to generate 200 data from this
> > function by Matlab. If it's available, could you kindly
> > describe the codes of Matlab? Really thank you so much.
> > 
> > Cheers
> > 
> does this work?
> 
> Y=@(x1,x2) (1+x1.^-2+ x2.^-1.5).^2;
> d = linspace(1,5,200);
> [x,y] = meshgrid(d);
> 
> Y(x,y); %here is your 200 x 200 matrix

Really sorry for the late reply and I do appreciate your
answer. Yes, it can work well. However, it seems the result
can not fit my requirement perfectly.

Originally, the outcome should be a "200x3" matrix
(200 examples, 1 output variable, and 2 input variables) 
comprising one column of output variable values and two 
columns of input variable values, not a "200x200" meshgrid.

Therefore, how can I generate a 200x3 matrix as follows:

             (Output Value) (Input1 Value) (Input2 Value)
Example 1.
Example 2.
    .
    .
    .
Example 200.

Really Thank you so much.