Matlab - finding x-value for known y-value from a linear plot?

Couldn’t really think of the best title for this thread, so if anyone can come up with something that describes the below better, please suggest!

Anyway, not used Matlab for quite a while, can just about remember the basics but I’m doing calculations based on data from a wind-tunnel lab I did recently.

The background isn’t that important, but I’ve got a load cell, and I want to manipulate the calculation data. I’ve managed to plot three sets of loading different loads against voltage data, taken the average then plotted a least-squares fit with polyval.

That’s fine, but I want to use this to find the force for a given voltage now.

So what matlab function do I use to do the reverse of plotting, and find the x value for a given y value on this new line (function) I’ve created?

I can’t really think of the name for doing this, which means I’m finding it hard to search for help on the internet!

Thanks in advance.

What you’re trying to do is linear interpolation, so see if that helps you search.

Thank you, ultrafilter, for some reason I couldn’t think of that term! The function was interp1.

Now I’ve just gotta work out why my data’s messed up.

I am not sure how you are using polyval here, but ployfit is what you want to use to fit a set of data. polyfit(x,y,1) will do a linear fit. [polyfit(x,y,2) does a quadratic, polyfit(x,y,3) does a cubic etc. etc.] You will get a vector of two terms from there. Then you do polyval([vector from polyfit],#), where # is the x value that you want to calculate y at.

Yes, got them mixed up in my OP, oops.