Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: import data in matlab
Posted:
Apr 15, 2009 8:12 PM


TideMan <mulgor@gmail.com> wrote in message <0564c8f0599f41b38424b9c2644dd8d1@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 redo the job every time I want to add a variable that is not at the end of my original dataset)...



