The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: import data in matlab
Replies: 3   Last Post: Apr 15, 2009 8:12 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Andrea Asoni

Posts: 10
Registered: 4/15/09
Re: import data in matlab
Posted: Apr 15, 2009 8:12 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

TideMan <> wrote in message <>...
> On Apr 16, 10:26=A0am, "Andrea Asoni" <> wrote:
> > hi,
> >
> > just started using matlab. I have the following problem. I think it is so=

> rt of standard but i couldn't figure out how to deal with it.
> >
> > I have data in .txt format that look like
> >
> > var1 var2 var3
> > 1 =A0 =A0 =A0. =A0 =A0 =A03
> > 2 =A0 =A0 6 =A0 =A0 =A04
> > 2 =A0 =A0 3 =A0 =A0 =A05
> >
> > I have about 141 vars and 90k obs. I'd like to drop the rows with missing=

> values. I found i can use the command X(any(isnan(X),2),:) =3D [];.
> > In order to do that i have to import the data separating the name of the =
> variable from the matrix (through the import wizard). Since different varia=
> bles have more or less missing values i cannot do this importing them as se=
> parate vectors...

> >
> > then i need to perform some calculations like newvar=3Df(var1, var2, var3=

> )... How do I say to Matlab that var1 is actually the first column of the m=
> atrix, var2 the second and so on?

> >
> > thanks,
> > Andrea

> From your description, I'm not sure what your problem is.
> You are importing matrix X using the import wizard, correct?
> It contains 141 columns and countless rows, correct?
> Using the command you presented, you delete the rows containing NaN.
> So what is the problem?
> To refer to the various columns of data, you simply use X(:,VarNo).
> The colon says get all the data in the column and VarNo tells it which
> column.

Thanks to both.
My problem basically was to know whether it is possible to tell matlab to form matrix X and keep the name of the variables (maybe with the import wizard) without having to go through the X(:,141) thingy (i have to re-do the job every time I want to add a variable that is not at the end of my original dataset)...

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.