0
$\begingroup$

"x is lambda, y is alpha, z is the factor of pressure"

clear[x, y, z, a, b, c];
x = {0.1248852, 0.0644999, 0.0363607, 0.6244261, 0.3224994, 0.1818034,
    0.1248852, 0.0644999, 0.0363607, 0.6244261, 0.3224994, 0.1818034, 
   0.1248852, 0.0644999, 0.0363607, 0.6244261, 0.3224994, 0.1818034};
y = {90, 90, 90, 90, 90, 90, 40, 40, 40, 40, 40, 40, 140, 140, 140, 
   140, 140, 140};
z = {7.023, 14.64, 26.508, 0.321, 1.223, 2.576, 6.381, 13.285, 23.499,
    0.326, 1.111, 2.368, 7.058, 14.457, 26.33, 0.327, 1.235, 2.598};
Print["data=", data = Transpose[{x, y, z}]]

z = NonlinearModelFit[data, {a*(y^c)*cos(bx)}, {a, b, c}, {x, y}]
z = Normal[model]
print["R^2=", R2 = model["RSquared"]]

Can someone tell me whats wrong with this code? I'm trying to get the coefficients a,b,c. The formula i'm using is (z=a*(y^c)*cos(bx))

$\endgroup$

closed as off-topic by m_goldberg, RunnyKine, user9660, MarcoB, Sjoerd C. de Vries Mar 27 '16 at 11:23

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, RunnyKine, Community, MarcoB, Sjoerd C. de Vries
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ You have invalid syntax in a*(y^c)*cos(bx) -- you probably want a*(y^c)*Cos[b*x] $\endgroup$ – m_goldberg Mar 27 '16 at 3:26
  • 1
    $\begingroup$ It might also be better not to assign data to variables which you are also going to use as formal variables. $\endgroup$ – Sjoerd C. de Vries Mar 27 '16 at 11:23
2
$\begingroup$

There are too many syntax errors in your code to describe them all.

nlm = NonlinearModelFit[data, {a*(y1^c)*Cos [b x1 ]}, {a, b, c}, {x1, y1}];
Show[ListPointPlot3D[data, PlotStyle -> PointSize[Medium]], 
     Plot3D[nlm[x, y], {x, 0, 1}, {y, 40, 140}]]

Mathematica graphics

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.