This will work with smooth data, and with points other than the first or the last of a dataset. It uses LabTalk to interactively calculate the tangent to a curve in a selected point.
1. Plot your dataset.
2. Copy the following code and paste it in the Script Window. (If the Script Window is not visible, active it by pressing ALT+3). Make sure that the Script Execution is checked (under the Edit menu in the Script Window).
3. Select all the pasted code and press ENTER to execute it. This will activate the Data Reader Tool.
4. Select one point of your dataset, or move left-right until you get it.
5. Press ENTER, and you'll have the tangent!
dotool 3; // Data Reader tool
def pointproc {
dotool -q;
%b=xof(%c); // X dataset for the current one
p1=(%C[index+1]-%C[index])/(%b[index+1]-%b[index]);
p2=(%C[index]-%C[index-1])/(%b[index]-%b[index-1]);
p=(p1+p2)/2;
c=y-p*x;
ftang(x)=$(p)*x+$(c);
layer -i200 ftang; // Plot as Line...
set ftang -c 4; // ...in blue
};
See the LabTalk help file for details about the dotool command and the PointProc macro to understand what I am doing here.
You can create a personal button to associate this script with. Consult the Origin help file, under any of these topics:
a. Script / Execution
b. Toolbar / Creating new
Jose Via, Origin WebRing member
Edited by - Jose on 04/30/2002 16:05:42