2
$\begingroup$

I have 2 lists:

datastr={0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 2., 0., \
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., \
0., 0., 0., 0., 0., 0., 0.};

dataB={548.29, 94.16, -322.15, -573.56, 495.01, 82.28, "eta11", "eta12", \
"eta13", "eta14", 307.53, -394.29, "eta15", 259.65, -245.74, "eta16", \
625.45, 738.91, 809.55, 2173.72, 3018.17, 122.09, 440.24, 340.35, \
"eta17", 740.92, 1317.23, 483.88, 675.24, "eta18", "eta19", "eta110", \
"eta111", "eta112", "eta113", "eta114", "eta115", "eta116", "eta117", \
"eta118", "eta119"}

I then do a summary of the multiple of the 2 lists and have:

etaa = (Total[dataJ*datastr])

I got:

etaa = -0.199 + 2. "eta26"

I want to set the "eta26" as a variables in a function

Funt[T_,eta26_]:=  (-0.199 + 2. "eta26")*T^2 +  "eta26"

The function Funt[T_,eta26_] is fitted to an experimental data set having values of the Funt and T to find value for the eta26.

Could you please suggest me how to extract the "eta26" in a list and set them as a variable in a Function as give above.

Thank and regards,

Anh

$\endgroup$
2
  • $\begingroup$ What is the definition of dataJ? $\endgroup$ Nov 13, 2019 at 5:22
  • $\begingroup$ Dear Rohit Namjoshi, it is a typo mistake. It should be dataB, not dataJ. Thank you $\endgroup$
    – Anh
    Nov 13, 2019 at 8:27

2 Answers 2

1
$\begingroup$

Convert the strings to symbols using ToExpression.

expr = ToExpression@dataB;
etaa = Total[expr*datastr]
(* 94.16 + 2. eta16 *)
$\endgroup$
2
$\begingroup$

You can do that using rules:

Funt[T_, eta26_] := (-0.199 + 2. "eta26")*T^2 + "eta26" /. "eta26" -> eta26
Funt[2, 3]

26.204

$\endgroup$
1
  • 1
    $\begingroup$ Thank you very much. It works fine for me $\endgroup$
    – Anh
    Nov 13, 2019 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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