#!MC 750 # diff_sum_2zones.mcr # This macro will take 2 XY data zones and calculate the (interpolated) # sum or difference between the 2 XY # curves. This allows you to find the sum/difference between 2 zones that may # not have the same # number of datapoints, or whose X locations do not necessarily correspond # w/ one another. # Created by Ardith Ketchum. Last edited 6/10/2002 # # Does the user want to calculate the sum or difference? # $!PromptforTextString |ds| Instructions = "Do you want to find the sum or difference? Enter:\n1 for Sum\n2 for Difference" $!Varset |Diff_or_Sum| = "Sum" $!Varset |Op| = "+" $!If |ds| == 2 $!Varset |Diff_or_Sum| = "Diff" $!Varset |Op| = "-" $!EndIf $!PromptforTextString |changevar| Instructions = "Enter the number of the variable to compute." $!Varset |chvar| = "v|changevar|" ## Determine which zone has more points, and set that to be the zone ## which is duplicated in the next function. $!FrameMode = TWOD $!VARSET |ZONESEQUAL| = 0 $!ACTIVEFIELDZONES = [1] $!VARSET |NUM_POINTS_1| = |MAXI| $!ACTIVEFIELDZONES = [2] $!VARSET |NUM_POINTS_2| = |MAXI| $!ACTIVEFIELDZONES = [1,2] $!VARSET |BIGZONE| = 1 $!VARSET |SMALLZONE| = 2 $!IF |NUM_POINTS_2| > |NUM_POINTS_1| $!VARSET |BIGZONE| = 2 $!VARSET |SMALLZONE| = 1 $!ENDIF ## Create zone to store difference values. $!DUPLICATEZONE SOURCEZONE = |BIGZONE| $!RENAMEDATASETZONE ZONE = |NUMZONES| NAME = '|Diff_or_Sum| of Variable' ## Interpolate values from smaller zone to the "Delta Y" zone, then calculate difference ## between the bigger zone and the "Delta Y" zone. $!AlterData Equation = "{Dummy} = 0" $!TWODAXIS YVAR = |NumVars| $!INVERSEDISTINTERPOLATE SOURCEZONES = [|SMALLZONE|] DESTINATIONZONE = |NUMZONES| VARLIST = [|changevar|] INTERPPTSELECTION = OCTANTNPOINTS INTERPNPOINTS = 8 $!TWODAXIS YVAR = 2 $!ALTERDATA [|NUMZONES|] EQUATION = '|chvar|=|chvar|[|NUMZONES|] |Op| |chvar|[|BIGZONE|]' $!FrameMode = XY $!CREATEXYMAP $!XYMAP [|NumXYMaps|] NAME = '|Diff_or_Sum| of Y' $!XYMAP [|NumXYMaps|] ASSIGN{XAXISVAR = 1} $!XYMAP [|NumXYMaps|] ASSIGN{YAXISVAR = |changevar|} $!XYMAP [|NumXYMaps|] ASSIGN{ZONE = |Numzones|} $!ACTIVEXYMAPS += [|NumXYMaps|] $!VIEW DATAFIT $!Redraw