From: Daniel Armyr on
Hi.
I have done a simulation where I calculate a certain value (v) for all combinations of three input values (x, y, z). These are currently represented in the variables X, Y, Z and V which are all three-dimensional mesh-grid-style arrays.

Now, I realize that variations of the variable Z are not so interesting, because I know exactly which number z should have. I therefore want to extract the 2-dimensional matrices from X, Y and V that represents the value V. The value z at which I want to cut is not necessarilly one of the values at which the data was sampled, so some form of interpolation is required.

I understand how I could do this using lots and lots of lines of code, but something in the back of my head says there should be an elegant solution to this that doesn't use a full page of code.

--DA
From: Bruno Luong on
"Daniel Armyr" <firstname(a)lastname.se> wrote in message <hs0fe4$kj1$1(a)fred.mathworks.com>...
> Hi.
> I have done a simulation where I calculate a certain value (v) for all combinations of three input values (x, y, z). These are currently represented in the variables X, Y, Z and V which are all three-dimensional mesh-grid-style arrays.
>
> Now, I realize that variations of the variable Z are not so interesting, because I know exactly which number z should have. I therefore want to extract the 2-dimensional matrices from X, Y and V that represents the value V. The value z at which I want to cut is not necessarilly one of the values at which the data was sampled, so some form of interpolation is required.
>
> I understand how I could do this using lots and lots of lines of code, but something in the back of my head says there should be an elegant solution to this that doesn't use a full page of code.
>

Take a look at function INTERP3

Bruno
From: Daniel Armyr on
> Take a look at function INTERP3

I did. It is a great function, but what is the easiest way to create the xi, yi and zi matrices for use in the interpolation? That is where things quickly started getting out of hand for me.

--DA
From: Bruno Luong on
"Daniel Armyr" <firstname(a)lastname.se> wrote in message <hs0m9j$gha$1(a)fred.mathworks.com>...
> > Take a look at function INTERP3
>
> I did. It is a great function, but what is the easiest way to create the xi, yi and zi matrices for use in the interpolation? That is where things quickly started getting out of hand for me.

I don't understand the problem you encountered. If you want a slice, the same way you use to create X, Y, Z, i.e., meshgrid() or ndgrid() should also do the job of creating xi, yi, zi.

Bruno
From: Daniel Armyr on
Yes, that is true of course. It means I need to keep the original data before I made grids of it, and I was hoping to be able to keep things simple by not having to do that.

But I suppose that is the simple solution. Thank you. Sometimes answers are there, but I am just too stubborn to see them.

--DA