DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Usin diadem to apply calculation to individual cells

Hello,
I'm trying to perform a calculation which takes the initial cell value from column 'x' adds this value to the first cell of column 'y' , creates a new column 'z' with this first new cell value, then adds the second cell value of column 'y' to this first value of column 'z'. Places this new value into the second cell of column 'z'. Using this new value in column 'z' adds the third cell of column 'y' to get the third value of column 'z' . Repeat for all cell values in column 'y'.
Easy in excel.......
Can anybody help....?
AdeK
 
0 Kudos
Message 1 of 8
(5,229 Views)

Perhaps the diagram would help the description....

I'm sure it must be easy......when you know how...

AdeK

0 Kudos
Message 2 of 8
(5,218 Views)
Hello AdeK!
 
You have to know that the DIAdem mathematics in the Analysis device or the FormulaCalc/ChnCalculate commands are row orientated. It is only possible to refer to values in the same row. I see no way to solve your problem with the standard features! I think you have to program a loop or build a special user script extension command to make this simple calculation.
 
Matthias
Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 3 of 8
(5,209 Views)
Hi Matthias,
Thanks for the reply.
So I must take a course in VBS script to solve this simple problem !
It may take some time !
AdeK
0 Kudos
Message 4 of 8
(5,155 Views)

Hello AdeK!

Sorry, but you are right! To help you learning VBS I can give you one possible solution:

Option Explicit
 
Dim i
Dim d
Dim nChnX
Dim nChnY
Dim nChnZ
 
nChnX = CNo("X")  ' get X channel number
nChnY = CNo("Y")  ' get Y channel number
 
' allocate result channel
Call ChnAlloc("Z", ChnLength(nChnY))
nChnZ = CNo("Z")
ChnLength(nChnZ) = ChnLength(nChnY)  ' DIAdem is a little bit special with this ;-)
 
d = ChdX(1,nChnX) ' start value
ChdX(1,nChnZ) = d
 
' calculation
For i=2 To ChnLength(nChnX)
  d = d + ChdX(i-1,nChnY)
  ChdX(i,nChnZ) = d
Next

Matthias

Matthias Alleweldt
Project Engineer / Projektingenieur
Twigeater?  
0 Kudos
Message 5 of 8
(5,148 Views)

Hi AdeK,

The calculations you want to carry out are indeed simple to accomplish in Excel, because this is what Excel was designed to do.  These same calculations are difficult to accomplish in DIAdem because this is NOT what DIAdem was designed to do.  DIAdem is at its best when you load long data columns into Data Portal channels and you want to graph or analyze the whole column at once.  DIAdem does pretty well when you want to run calculations on multiple entire channels of the sort Ch5 = Ch1 + Ch2*sin((Ch3 - Ch4)/pi).  These calculations run efficiently and they're not too hard to construct in the Channel Calculator.

But DIAdem has no native tools to assist you in setting up a relationship between individual cells in one or more channels.  Excel does this elegantly by assigning the entire function to each cell.  That gives you all the cell-by-cell flexibility you could wish for, but it comes at a cost.  If you want to do the sort of calculations that DIAdem does easily-- long column manipulations, you have to copy the same formula into every cell of that column, potentially millions of times.  Each of these cell functions has to be parsed separately and run individually.  Deep array analysis is the bane of Excel the same way that arbitrary cell referencing is the bane of DIAdem.  Said differently, deep array analysis is the natural domain of DIAdem in the same way that arbitrary cell referencing is the natural domain of Excel.  You can accomplish both types of analysis in both DIAdem and Excel, but some analysis types are just naturally easier in each respective application.

How are you loading your data into DIAdem?  Perhaps those cell values really should be loaded in as scalar properties instead of channel values.  Where does your data come from and what is the data file (or data base) format?  It may be that we can make this analysis much more natural for DIAdem by simply changing the way the data is being loaded into DIAdem.  What is the end goal of these calculations?  Do you want to display your results in a graph (if so what type), or in a table?

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 6 of 8
(5,118 Views)

Hi Matthias,

The script works perfectly !

I can delay the VBS course to another day...

Regards and thanks again.

AdeK

0 Kudos
Message 7 of 8
(5,099 Views)

Hi Brad,

I realise Diadem is a very powerful tool for data analysis, and I cannot work without it.

Therefore because the tool is so good, I expect it can easily perform tasks which I know can be performed in excel.

But you are completely right, they should not be compared.

I can never go back to excel !

I will book a VBS course when I have some time.

AdeK

 

0 Kudos
Message 8 of 8
(5,098 Views)