Assuming you have already performed linear regression using polyfit
function and obtained the fitting coefficients p
for your data:
main.m45 chars2 lines
You can then compute the predicted voltage at 10 seconds as follows:
main.m20 chars2 lines
This uses the fitted coefficients p
to evaluate the polynomial at x=10
.
Alternatively, you can also directly extract the slope and intercept a
and b
of the linear fit, and use them to compute the predicted v1
:
main.m39 chars3 lines
Here, polyfit
returns the coefficients in reverse order, so we extract a
as the first element and b
as the second element of the output. We then use them to compute v1
as a*10 + b
.
gistlibby LogSnag