How to solve "x" values for quadratic equation with varying "y" values

7 views (last 30 days)
I use a standard curve to find concentrations of solutions based on absorbance values. My standard curve best fit is a second order polynomial. I want to use matlab to solve this quadratic equation where the x values are concentrations using the y values which are absorbance.
For example, my standard curve equation is in the form of x^2+2x+1= y, where there are over a 100 y values. Can I use matlab to find the x values for the data set of y values?
I tried importing my data and saved it as var1 and used this command:
>> solve(x + 1 == VarName1 ,x)
It gave me:
Warning: 5 equations in 1 variables.
In C:\Program Files\MATLAB\R2013a\toolbox\symbolic\symbolic\symengine.p>symengine at 56
In mupadengine.mupadengine>mupadengine.evalin at 97
In mupadengine.mupadengine>mupadengine.feval at 150
In solve at 170
Warning: Explicit solution could not be found.
> In solve at 179
ans =
[ empty sym ]

Answers (1)

Star Strider
Star Strider on 28 Aug 2015
It’s not easy to visualise what you’re doing, so I’m making a guess with this. Note that for it to work, your ‘y’-data have to be organised in columns. This routine should estimate the ‘x’ values for each vector of ‘y’ values:
x = repmat(1:5, 5, 1); % Create ‘x’ Data
y = x.^2 + 2*x + 1 + 0.1*randn(size(x)); % Create ‘y’ Data + Noise With ‘y’-Data In Columns
yf = @(x) x.^2 + 2*x + 1; % Objective Function
for k1 = 1:size(y,2)
SSECF = @(b) sum((y(:,k1) - yf(b)).^2); % Sum-Squared-Error Cost Function
[X(k1), SSE(k1)] = fminsearch(SSECF, 1); % Estimate ‘X’, Return Sum-Squared-Error
end

Categories

Find more on Quadratic Programming and Cone Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!