On Mar 19, 8:10 pm, Charlie <charliebis...@gmail.com> wrote:
> Hello everyone,
>
> I have some data that I am trying to fit to an equation, but am unsure
> ifpolyfitnis doing what I want it to do.
>
> I have three columns of data, all of the same size (~500 entries
> each): Phase, Temperature, and Concentration. I know that my
> concentration is a function of both temperature and phase, which
> follows the equation:
>
> Concentration = C0 + C1*phase + C2*phase^2 + C3*phase^3 +
> C4*phase^4 ;
>
> where
>
> C0 = C00 + C01*T + C02*T^2 + C03*T^3
> C1 = C10 + C11*T + C12*T^2 + C13*T^3
> C2 = C20 + C21*T + C22*T^2 + C23*T^3
> C3 = C30 + C31*T + C32*T^2 + C33*T^3
> C4 = C40 + C41*T + C42*T^2 + C43*T^3
>
> so the entire equation when put all together looks like this:
>
> Concentration = (C00 + C01*T + C02*T^2 + C03*T^3) + (C10 + C11*T +
> C12*T^2 + C13*T^3)*phase + (C20 + C21*T + C22*T^2 + C23*T^3)*phase^2
> + (C30 + C31*T + C32*T^2 + C33*T^3)* phase^3 + (C40 + C41*T +
> C42*T^2 + C43*T^3)*phase^4 ; *** equation 1
>
> So I have my concentration data, and I have my T data, and my Phase
> data. Is there anyway to use matlab to solve for my unknown constants:
> C00 C01 C02 C03 C20 C21 C22 C23 C30 C31 C32 C33 C40 C41 C42 C43 ?
>
> I have recieved some help on this matter, and told thatpolyfitncan
> do this simple regression, but It is giving me some headaches. I think
> maybe because of the way the equation 1 works.
>
> I have a nx2 array (Phase and Temperature), and
> my concentrations are an nx1 vector (C)
>
> I tried the following withpolyfitn:
>
> [pe,te] = meshgrid(0:4,0:3);
> modelterms = [pe(:),te(:)];
> P =polyfitn(PT, C, modelterms);
>
> now this returns my 20 constants, and says the RMSE is only 0.56 and
> my R^2=0.999. So I would assume these constants give a good fit to my
> data.
>
> HOWEVER, when I take these 20 generated constants, and stick them back
> into my equation 1 for concentration, the result looks nothing like
> the original concentration data.
>
> so I am thinking my issue is with how I am defining my model terms? or
> maybe the form of my equation in general?
>
> any help would be greatly appreciated, I've been struggling with this
> for some time now.
>
> Also, is there any other way I can go about determining these
> constants?
>
> cheers,
I've figured it out, thanks to those who emailed me. it was just a
simple typo! :)
