Asked by eternal
on 24 Apr 2011

I was given a polynomial similar to deltaP=F(q,v)=(u1+u2*v)*(n1+n2*q+n3*q.^2+n4*q.^3) where a linear and cubic polynomial are multiplied together. also I was given 2 arrays of data in order to solve for the n's and q's using polyfit or some other method. My question is how do I plot the deltaP? My current code solves for all the variables, then I define the function, but when I go to plot it I get an undefined q error message, does fplot work for this type of function, as it is still a 2d graph? or perhaps I am doing something wrong.

MATLAB code cfm = [0 17.8 25.2 30.9 35.7 39.9 43.7 47.2 48.5]'; h20 = [.095 .06 .045 .043 .035 .03 .02 .008 0]'; u=polyfit(cfm,h20,3) n=polyfit(cfm,h20,1) f=@(v, q)(u(1)+u(2)*v)*(n(1)+n(2)*q+n(3)*q.^2+n(4)*q.^3); fplot(f,[0 48.5]); MATLAB code thanks for any help

Answer by Matt Fig
on 24 Apr 2011

This is confusing to me. If I plot your vectors:

plot(cfm,h20)

It doesn't look cubic, though you could fit a cubic polynomial to this data. Part looks linear and part looks maybe quadratic, perhaps you meant that you need a piecewise fit? In your solution, u and n are switched, i.e., u should have two values and n should have 4 if we believe your function definition. Also, you have mixed up the order of the coefficients returned from POLYFIT.

I don't see how the function f can be related to your data. Is this homework?

Use EZPLOT to plot implicitly defined functions.

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments