Thread Subject: How to generate data by Matlab?

Subject: How to generate data by Matlab?

From: Hero Lee

Date: 25 Oct, 2007 20:23:06

Message: 1 of 3

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

Subject: How to generate data by Matlab?

From: Dan Haeg

Date: 26 Oct, 2007 00:38:40

Message: 2 of 3

"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

Subject: How to generate data by Matlab?

From: Hero Lee

Date: 16 Jan, 2008 01:06:04

Message: 3 of 3

"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.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com