Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Matrix manipulation

Subject: Matrix manipulation

From: Rachit

Date: 10 Dec, 2010 19:52:21

Message: 1 of 4

I have 149 x 132 matrix for 3 variables Xdata, Ydata and Zdata.

I have NaN values in the Zdata. I want to get a new matrix for Zdata where there are no Nan Values. Also for the same numbers which are Non Nan values I would like to get the postions so that I can get the values at the same positions in the Xdata and Ydata which will help me in constructing a matrix of (some number x 3) with no Nan values.

Any help will be appreciated.

Thanks,

RP

Subject: Matrix manipulation

From: Sean de

Date: 10 Dec, 2010 20:02:21

Message: 2 of 4

"Rachit " <racpsine@gmail.com> wrote in message <idu0dl$t16$1@fred.mathworks.com>...
> I have 149 x 132 matrix for 3 variables Xdata, Ydata and Zdata.
>
> I have NaN values in the Zdata. I want to get a new matrix for Zdata where there are no Nan Values. Also for the same numbers which are Non Nan values I would like to get the postions so that I can get the values at the same positions in the Xdata and Ydata which will help me in constructing a matrix of (some number x 3) with no Nan values.
>
> Any help will be appreciated.
>
> Thanks,
>
> RP

A few hints:

idx = isnan(Zdata);
Zdata(idx) = something;

idx_non_nans = ~idx;

Also look at John D'Errico's inpaint_nans on the FEX.

Subject: Matrix manipulation

From: Walter Roberson

Date: 10 Dec, 2010 20:14:13

Message: 3 of 4

On 10-12-10 01:52 PM, Rachit wrote:
> I have 149 x 132 matrix for 3 variables Xdata, Ydata and Zdata.
>
> I have NaN values in the Zdata. I want to get a new matrix for Zdata where
> there are no Nan Values. Also for the same numbers which are Non Nan values I
> would like to get the postions so that I can get the values at the same
> positions in the Xdata and Ydata which will help me in constructing a matrix
> of (some number x 3) with no Nan values.
> Any help will be appreciated.

I don't think I caught everything you want to do, but it sounds to me like you
might benefit from John D'Errico's Matlab File Exchange (FEX) contribution
"inpaint_nans" (I think it is called.)

Subject: Matrix manipulation

From: Rachit

Date: 10 Dec, 2010 21:33:05

Message: 4 of 4

Thanks guys but I assume the file by John does linear interpolation on the Nan Values to give some values close to the numbers which are present. I have not looked closely though.

I did try the following command
i = find(~isnan(Zdata)); to find the locations at which Nan values are not present.
Eg I have ZData = [ 0 31 23
                             Nan 2 Nan
                             1 2 Nan]
I would get I = [1
                        3
                        4
                        5
                        6
                        7]
Now I would like to take these values of I and get the data from Xdata and Ydata at the same locations. How should I proceed with that ?

Also How can I get a new matrix for Z data with NaN values omitted..thus reducing the size of the matrix also ?

RP

Walter Roberson <roberson@hushmail.com> wrote in message <idu1mm$30b$2@canopus.cc.umanitoba.ca>...
> On 10-12-10 01:52 PM, Rachit wrote:
> > I have 149 x 132 matrix for 3 variables Xdata, Ydata and Zdata.
> >
> > I have NaN values in the Zdata. I want to get a new matrix for Zdata where
> > there are no Nan Values. Also for the same numbers which are Non Nan values I
> > would like to get the postions so that I can get the values at the same
> > positions in the Xdata and Ydata which will help me in constructing a matrix
> > of (some number x 3) with no Nan values.
> > Any help will be appreciated.
>
> I don't think I caught everything you want to do, but it sounds to me like you
> might benefit from John D'Errico's Matlab File Exchange (FEX) contribution
> "inpaint_nans" (I think it is called.)

Tags for this Thread

No tags are associated with this thread.

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.

Contact us