05-01-2018 01:31 PM
Hi,
I am trying to automatically plot a exponential curve with two co-ordinates.
Please help me with the format that i should be using in the formula
Example of the plot is as attached below
Thanks in advance
Best Regards
Naseem
05-08-2018 09:49 AM
I plugged in your [x1, y1] and [x2, y2] values into an online calculator Symolab to get your a and b values for the y = a(b^(x)) exponential equation. are you looking to programmatically create a channel to reflect this curve or are you looking to solve for a and b in DIAdem (not sure that is a function)?
05-14-2018 05:10 AM
Extermly sorry for late reply.
I am look for both, calculating their values and reflecting them on achannel
05-14-2018 05:18 AM
Thanks a ton for your reply.
In Detail,
I am trying to generate an Automatic Report after the data acquisition.
I have one group with seven channels. In these channels,
Channel 1- Time
Channel 2- Speed 1
Channel 3- Speed 2
Channel 4- Speed 3
Channel 5 - x co-ordinate value for channel 3
Channel 6 - x co-ordinate value for channel 4
Channel 7- other value
With these data, I have created XY Graph 1: using Channel 1 as X and 2,3,4 as Y data.
Graph 2: Then I calculated mean value of Channel 3 and Channel 4 and saved them as a separate channels.
Now I have my two co-ordinates saved in the same Group as Mean 2, Mean 3 as (y1, y2) and Channel 5 and Channel 6.(x1, x2) Now how shall I proceed to plot these two co-ordinates as an exponential curve? I tried draging them on to the XY graph, but couldnot succeed connecting them through a line or exponential curve.
05-15-2018 08:37 AM - edited 05-15-2018 08:40 AM
Hi I used your original values in the example. I took the A and B values from the online calculator result in my previous post. This is the input and output groups in the photo under the code: I am not sure how to program a reliable system of exponential equations solver so I used the calculated a, b specific for your example
Option Explicit 'Forces the explicit declaration of all the variables in a script. ' Set up variables Dim xChnl, yChnl Set xChnl = Data.Root.ChannelGroups(1).Channels("x") ' Channel with your x coordinates Set yChnl = Data.Root.ChannelGroups(1).Channels("y") ' Channel with your y coordinates Dim vals: vals = 10000 ' How many values do you want in the output channel Dim a: a = 40 * (4^(11/739)) * (5^(728/739)) ' A for y = A * B^(x) Dim b: b = (5/4)^((1/2956)) ' B for y = A * B^(x) ' Call the helper function Call expoChannel(xChnl, yChnl, vals, a, b, "Result") ' Help function to generate an exponential channel Function expoChannel(x2coorChnl, y2coorChnl, numOfVals, a, b, outChannelName) Call x2coorChnl.ChannelGroup.Channels.Add(outChannelName, DataTypeChnFloat64) Dim x1: x1 = x2coorChnl.Values(1) Dim x2: x2 = x2coorChnl.Values(2) Dim y1: y1 = y2coorChnl.Values(1) Dim y2: y2 = y2coorChnl.Values(2) Dim timeInc: timeInc = (x2 - x1) / numOfVals Dim i, outChannel Set outChannel = x2coorChnl.ChannelGroup.Channels(outChannelName) For i = 1 To numOfVals Step 1 outChannel.Values(i) = a * (b ^ (x1 + (timeInc * (i - 1)))) Next End Function
05-16-2018 02:38 AM
Thanks a lot for your help.
05-16-2018 03:01 AM
But i want my graph to reflect reflect as attached below
The equation is y=a*b^x as you have mentioned.
05-16-2018 03:03 AM
Is it ok to asume r estimate a and b to be 1 always?
05-16-2018 07:44 AM
Well if you look back to the original image you posted, 200 and 250 were your y1 and y2. In the last one you put them as your x1, x2. You have to recalculate the A and B values if you want to switch them around
05-17-2018 09:40 AM
Thank you. Will do it