From: Charles on
Hi all,

the interp1 function is used in reading off the values of the y-axis by providing the x-axis. Is there a way to do the reverse? I.e providing the values on the y-axis and having the function give the corresponding value on the x-axis.

Thanks for your contributions
Charles.
From: Mark Shore on
"Charles " <nkwosman(a)yahoo.com> wrote in message <htc6hc$if9$1(a)fred.mathworks.com>...
> Hi all,
>
> the interp1 function is used in reading off the values of the y-axis by providing the x-axis. Is there a way to do the reverse? I.e providing the values on the y-axis and having the function give the corresponding value on the x-axis.
>
> Thanks for your contributions
> Charles.

interp1 interpolates between points. "reading off the values" suggests you need to read the documentation. Enter doc interp1 or help interp1 from the command line, or look it up in help.

How would a MATLAB function "know" which vector was x and which y? Once you've read the documentation (it's short) then just reverse the order of the two variables.
From: Charles on
Hi, thanks for taking your time to respond. Actually, I realized the same thing after posting this message...anyway, thanks so much for taking out ur time to help, I appreciate it.

"Mark Shore" <mshore(a)magmageosciences.ca> wrote in message <htc7h7$lvp$1(a)fred.mathworks.com>...
> "Charles " <nkwosman(a)yahoo.com> wrote in message <htc6hc$if9$1(a)fred.mathworks.com>...
> > Hi all,
> >
> > the interp1 function is used in reading off the values of the y-axis by providing the x-axis. Is there a way to do the reverse? I.e providing the values on the y-axis and having the function give the corresponding value on the x-axis.
> >
> > Thanks for your contributions
> > Charles.
>
> interp1 interpolates between points. "reading off the values" suggests you need to read the documentation. Enter doc interp1 or help interp1 from the command line, or look it up in help.
>
> How would a MATLAB function "know" which vector was x and which y? Once you've read the documentation (it's short) then just reverse the order of the two variables.
From: Justme on
Tideman,
Thank you for your input and advice. Forgive the lateness of this reply. I've been away on travel. You are right in your second statement, that the most plausible method would be to exclude the NANs. I should rephrase my previous example though...when I said 'interp1(data1,data1,data2,'extrap'),' what I really meant was interp1(datx1,datay1,data2,'extrap') where I am reading the first two variables from the same file, but different columns, whereas data2 is from a different file source. I tried the script that you suggested and still find myself producing nans. I wonder if I am declaring the right variables? I figure I would cover myself so forgive the question but when you say igood=~isnan(y); ybar=mean(y(igood)); y should be replaced by the variable I use to calculate my mean in this case correct?

"Justme " <sadsd(a)aol.com> wrote in message <ht18vp$5hp$1(a)fred.mathworks.com>...
> Hey matlab community,
> Question. I currently am using the interp1 function when interpolating data being read from a couple of files.
>
> Everything seems to work fine accept when I am trying to print the graph values. The graph is printed out fine, able to output Min and Max. However, usually when I try to print out an average, I keep running into NANs. I've done several troubleshooting methods..the only thing I can really think of is that I am not using the interp1 function properly.
>
> I've read that there is an 'extrap' function that takes into account NaNs? But I am unfamiliar as to how to use this. Shouldn't I just be able to say Function1 = interp1(data1,data1,data2,'extrap')? Does that makes sense?
>
> Thanks for the help in advance
>
> ~GJ
From: Justme on
Argh,
Sorry. I figured it out...I needed my morning cup of oatmeal to stimulate the brain..Thank you so much Tideman. It works very well now.

"Justme " <sadsd(a)aol.com> wrote in message <ht18vp$5hp$1(a)fred.mathworks.com>...
> Hey matlab community,
> Question. I currently am using the interp1 function when interpolating data being read from a couple of files.
>
> Everything seems to work fine accept when I am trying to print the graph values. The graph is printed out fine, able to output Min and Max. However, usually when I try to print out an average, I keep running into NANs. I've done several troubleshooting methods..the only thing I can really think of is that I am not using the interp1 function properly.
>
> I've read that there is an 'extrap' function that takes into account NaNs? But I am unfamiliar as to how to use this. Shouldn't I just be able to say Function1 = interp1(data1,data1,data2,'extrap')? Does that makes sense?
>
> Thanks for the help in advance
>
> ~GJ