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:
Find Y values from a given X values

Subject: Find Y values from a given X values

From: josevm

Date: 3 Dec, 2012 10:28:07

Message: 1 of 5

I've a set of experimental data which has a like Gaussian profile. I want to find the values of X or (index) for Y0 (Y maximum), Y0/10, Y0/20... Y)/90 like that from the raw data. Y0 and its index can be found from the 'max' function, but corresponding to Y0/10, Y0/20 and all there are no discrete X values. The X values have to come from interpolated data. The "interp1" option doesn't work since it gives Y for a given x. I need the reverse. Thanks in advance

Subject: Find Y values from a given X values

From: Torsten

Date: 3 Dec, 2012 11:44:08

Message: 2 of 5

"josevm" wrote in message <k9hurn$iki$1@newscl01ah.mathworks.com>...
> I've a set of experimental data which has a like Gaussian profile. I want to find the values of X or (index) for Y0 (Y maximum), Y0/10, Y0/20... Y)/90 like that from the raw data. Y0 and its index can be found from the 'max' function, but corresponding to Y0/10, Y0/20 and all there are no discrete X values. The X values have to come from interpolated data. The "interp1" option doesn't work since it gives Y for a given x. I need the reverse. Thanks in advance

Interchange the roles of X and Y in the call to interp1:
xi = interp1(Y,X,yi);

Best wishes
Torsten.

Subject: Find Y values from a given X values

From: josevm

Date: 3 Dec, 2012 12:31:09

Message: 3 of 5

"Torsten" wrote in message <k9i3a8$2nv$1@newscl01ah.mathworks.com>...
> "josevm" wrote in message <k9hurn$iki$1@newscl01ah.mathworks.com>...
> > I've a set of experimental data which has a like Gaussian profile. I want to find the values of X or (index) for Y0 (Y maximum), Y0/10, Y0/20... Y)/90 like that from the raw data. Y0 and its index can be found from the 'max' function, but corresponding to Y0/10, Y0/20 and all there are no discrete X values. The X values have to come from interpolated data. The "interp1" option doesn't work since it gives Y for a given x. I need the reverse. Thanks in advance
>
> Interchange the roles of X and Y in the call to interp1:
> xi = interp1(Y,X,yi);
>
> Best wishes
> Torsten.

I think, "interp1" assumes "x" to be equally spaced. I tried this before but couldn't succeed.

Subject: Find Y values from a given X values

From: dpb

Date: 3 Dec, 2012 12:57:25

Message: 4 of 5

On 12/3/2012 6:31 AM, josevm wrote:
> "Torsten" wrote in message <k9i3a8$2nv$1@newscl01ah.mathworks.com>...
>> "josevm" wrote in message <k9hurn$iki$1@newscl01ah.mathworks.com>...
>> > I've a set of experimental data which has a like Gaussian profile. I
>> want to find the values of X or (index) for Y0 (Y maximum), Y0/10,
>> Y0/20... Y)/90 like that from the raw data. Y0 and its index can be
>> found from the 'max' function, but corresponding to Y0/10, Y0/20 and
>> all there are no discrete X values. The X values have to come from
>> interpolated data. The "interp1" option doesn't work since it gives Y
>> for a given x. I need the reverse. Thanks in advance
>>
>> Interchange the roles of X and Y in the call to interp1:
>> xi = interp1(Y,X,yi);
>>
...

> I think, "interp1" assumes "x" to be equally spaced. I tried this before
> but couldn't succeed.

No it doesn't. The 'x' values (the independent variables in the
interpolating function) have to be strictly increasing, but they may be
spaced at whatever the data available is. Only if you use the shorthand
notation of only giving a Y and an XI are the input X assumed to be
1:length(Y)

--

Subject: Find Y values from a given X values

From: josevm

Date: 3 Dec, 2012 18:07:14

Message: 5 of 5

dpb <none@non.net> wrote in message <k9i7jl$si2$1@speranza.aioe.org>...
> On 12/3/2012 6:31 AM, josevm wrote:
> > "Torsten" wrote in message <k9i3a8$2nv$1@newscl01ah.mathworks.com>...
> >> "josevm" wrote in message <k9hurn$iki$1@newscl01ah.mathworks.com>...
> >> > I've a set of experimental data which has a like Gaussian profile. I
> >> want to find the values of X or (index) for Y0 (Y maximum), Y0/10,
> >> Y0/20... Y)/90 like that from the raw data. Y0 and its index can be
> >> found from the 'max' function, but corresponding to Y0/10, Y0/20 and
> >> all there are no discrete X values. The X values have to come from
> >> interpolated data. The "interp1" option doesn't work since it gives Y
> >> for a given x. I need the reverse. Thanks in advance
> >>
> >> Interchange the roles of X and Y in the call to interp1:
> >> xi = interp1(Y,X,yi);
> >>
> ...
>
> > I think, "interp1" assumes "x" to be equally spaced. I tried this before
> > but couldn't succeed.
>
> No it doesn't. The 'x' values (the independent variables in the
> interpolating function) have to be strictly increasing, but they may be
> spaced at whatever the data available is. Only if you use the shorthand
> notation of only giving a Y and an XI are the input X assumed to be
> 1:length(Y)
>
> --

Ok, as you told, the independent variables in the interpolating function have to be strictly increasing. If I make Y as the independent variable, in my case the Y data has a Gaussian like profile as I told before. So this is not applicable, I think.

I'm just writing down the 'interp1' function that I tried (t and p have same length);
t=1:18836;
p=y(:,1);
c=interp1(p,t,2.34e-6, 'spline')

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