Mathematica : equivalent point

มีคนโพสท์ถามที่พันทิป http://pantip.com/topic/34236148

pt1

pt1

pt1

pt1

ผมได้ลองใช้ Mathematica เขียนแบบง่ายๆได้ตามนี้ครับ

pantipPlot

โดย code ที่เขียนก็ประมาณนี้ครับ



data={{0.,4.04},{1.,4.6},{2.,5.01},{3.,5.38},{4.,5.84},{4.5,6.31},{5.,9.99},{5.5,10.7},{6.,10.97},{6.5,11.12},{7.,11.22},{8.,11.35},{9.,11.44},{10.,11.51},{11.,11.57},{12.,11.62}};

SplitDat[np1_List,np2_List]:=Module[{dat1,dat2},
dat1=data[[np1[[1]];;np1[[2]]]];
dat2=data[[np2[[1]];;np2[[2]]]];
{dat1,dat2}
];

genLineEq[datsplitted_,x_]:=Module[{dat1,dat2,lm1,lm2},
dat1=datsplitted[[1]];
dat2=datsplitted[[2]];
lm1=LinearModelFit[dat1,x,x];
lm2=LinearModelFit[dat2,x,x];
{lm1,lm2}
];

pantipPlot1[pospnts1_List,pospnts2_List,verpos1_,verpos2_,wantx_]:=Module[{x,eq1,eq2,eq3,xx,wanty},
{eq1,eq2}=genLineEq[SplitDat[pospnts1,pospnts2],x];
eq3=Fit[{{verpos1,((eq2[verpos1]-eq1[verpos1])0.5)+eq1[verpos1]},{verpos2,((eq2[verpos2]-eq1[verpos2])0.5)+eq1[verpos2]}},{1,xx},xx];
wanty=eq3/.{xx->wantx};

Show[Plot[{eq1[x],eq2[x]},{x,0,14},PlotRange->{0,13},PlotLabel->Style["Standardization NaOH with KHP",Bold,Medium],Frame->True,FrameLabel->{"V of NaOH (ml)","pH of KHP"},GridLines->Automatic,GridLinesStyle->Directive[Dotted, Gray],PlotStyle->{{Dashed,Gray},{Dashed,Gray}}],ListPlot[data,Joined->True,PlotStyle->Blue,PlotMarkers->Automatic],
Graphics[{Dashed,Line[{{verpos1,eq1[verpos1]},{verpos1,eq2[verpos1]}}]}],
Graphics[{Dashed,Line[{{verpos2,eq1[verpos2]},{verpos2,eq2[verpos2]}}]}],
Graphics[{Red,Dashed,Line[{{verpos1,((eq2[verpos1]-eq1[verpos1])0.5)+eq1[verpos1]},{verpos2,((eq2[verpos2]-eq1[verpos2])0.5)+eq1[verpos2]}}]}],
Graphics[{{Red,Line[{{wantx,0},{wantx,wanty}}]},Text[wanty,{wantx,wanty},{-1,0}]}]
]
];

Manipulate[pantipPlot1[{1,endLine1},{begLine2,16},begVerLeft,begVerRight,xwant],
{{endLine1,6},2,8,1,Appearance->"Labeled"},{{begLine2,8},8,16,1,Appearance->"Labeled"},
{{begVerLeft,3},1,6,Appearance->"Labeled"},
{{begVerRight,5},4.5,13,Appearance->"Labeled"},
{xwant,0,12,Appearance->"Labeled"}
] 

ภาษาวุลแฟรม วอลแฟรม โวลแฟรม

ภาษา Wolfram นี้ที่จริงก็คือรูปแบบคำสั่งหรือภาษาที่ใช้งานในโปรแกรม Mathematica ครับ แต่อาจเป็นเรื่องของการตลาดที่ทำให้มีการแยกตัวของภาษาออกมาจากโปรแกรม Mathematica แล้วตั้งชื่อใหม่ให้กับภาษานี้ Stephen Wolfram เจ้าของบริษัทและเป็นผู้ที่คิด/สร้าง Mathematica ถึงกับ โพสท์ถามเลยว่าจะเรียกรูปแบบคำสั่งหรือภาษาที่ใช้ใน Mathematica นี้ว่าอะไรดี http://blog.stephenwolfram.com/2013/02/what-should-we-call-the-language-of-mathematica/  แต่สุดท้ายก็มาจบที่ Wolfram Language ครับ ถ้าสนใจและอยากทดลองใช้งานภาษานี้ให้ลองไปเล่นที่ Wolfram Programming Lab ดูครับ หรืออาจจะหา Raspberry Pi มาใช้งานสักตัวดูครับ http://www.wolfram.com/raspberry-pi  เพราะเค้าให้ใช้ Mathematica ฟรีครับ ส่วนใครที่อยากเรียนรู้การใช้งานพื้นฐานภาษา Wolfram นี้ผมแนะนำให้อ่านหนังสือนี้ครับ An Elementary Introduction to the Wolfram Language เขียนโดย Stephen Wolfram เองเลยครับ ซึ่งอ่านได้ฟรีที่ http://www.wolfram.com/language/elementary-introduction/

ลองเล่นและเรียนรู้ดูครับ ภาษานี้สนุกครับ

 

 

 

 

 

%d bloggers like this: