DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting Exponential Curve with two co-ordinates automatically in diadem

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

 

0 Kudos
Message 1 of 10
(4,544 Views)

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)?

0 Kudos
Message 2 of 10
(4,472 Views)

Extermly sorry for late reply.

I am look for both, calculating their values and reflecting them on achannel

0 Kudos
Message 3 of 10
(4,439 Views)

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.

0 Kudos
Message 4 of 10
(4,437 Views)

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


1.JPG

0 Kudos
Message 5 of 10
(4,426 Views)

Thanks a lot for your help.

 

0 Kudos
Message 6 of 10
(4,416 Views)

 

But i want my graph to reflect reflect as attached below

The equation is y=a*b^x as you have mentioned. 

 

 

 

0 Kudos
Message 7 of 10
(4,415 Views)

Is it ok to asume r estimate a and  b to be 1 always?

0 Kudos
Message 8 of 10
(4,414 Views)

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

0 Kudos
Message 9 of 10
(4,407 Views)

Thank you. Will do it

0 Kudos
Message 10 of 10
(4,363 Views)