MATLAB: How to solve an equation with two variables but one variable is an array

quadraticsemilogxvariable array

Hi, I'm still relatively new to coding, and I have a question about solving a quadratic equation, then using the results to graph using semilogx. I have a quadratic equation with two variables, one of which I'm solving for and the other an array of values. More specifically, I'm solving for L and one of the coefficients is 1/(1+x) but x goes from 0 to 10^10 and I need to find the roots for every value of x on intervals of 100. I then need to plug the answer from the equation into another equation, and graph x vs that answer. I tried syms and roots, but I keep getting errors. Any tips? Thank you!

Best Answer

I assume log10 is what you want. If not you can easily change it. You might have memory problems for 1e10.
x=0:1e8;
pKa=0.000138;%10^log10(0.000138) easier
L=(-pKa+sqrt(pka^2+4*pKa./(1+x)))/2;%some simple algebra helps
pH=-log10(L);
semilogx(x,L);