Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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

>
> 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]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.