Search All of the Math Forum:

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

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

 Messages: [ Previous | Next ]
 Andrea Asoni Posts: 10 Registered: 4/15/09
Re: import data in matlab
Posted: Apr 15, 2009 8:12 PM

TideMan <mulgor@gmail.com> wrote in message <0564c8f0-599f-41b3-8424-b9c2644dd8d1@v23g2000pro.googlegroups.com>...
> On Apr 16, 10:26=A0am, "Andrea Asoni" <andrea.as...@lycos.com> 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

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

Date Subject Author
4/15/09 Andrea Asoni
4/15/09 jrenfree@gmail.com
4/15/09 Derek Goring
4/15/09 Andrea Asoni