# Calculations using values in the channels

Is there a way to make simple calculations (addition/subtraction) of single values selected channels?   New user DIAdem, so I'm not at all familiar with the scripts.  Looks like it should be a simple command, and I'm right on it.

Thank you

Shannon

Hello Shannon,.

It seems to me that you do not want to add two or more 'cells' (to use the jargon of Excel) together.

DIAdem manages data such as channels, not individual cells. If the approach to add two cells in DIAdem works like this:

The variable SMC allows you to access a 'cell' in a channel, using the following sequence parameters:

ChD (X, Y)

where X is the line number of the table of channel, and Y is the name of the channel (column) or the number of the cell you want to access.

For example, this expression here calculates the result of adding the value of line 2 of the channel called "Temperature_1" and the channel called "Temperature_2" of the example data set that takes over at the start of tiara. In this case, R1 is a real internal DIAdem variable that stores a single value.

R1 = SEC (2, Ch("/Temperature_1")) + SMC (2, Ch("/Temperature_2"))

The calculation above can be entered in the "Calculator" which is available in MODE of DIAdem and DIAdem analysis in the toolbar. I hope it's useful, please let us know if you have additional questions.

Otmar

Tags: NI Software

### Similar Questions

• Formula to find the value of the channel

Hi all

Support: Dat file containing the value of time and acceleration. Now, there are only two Channels.  Channel 1 is time. Channel 2's acceleration.

Step 1: Create more than two channels. Channel 3 and channel 4

Step 2: go to the analysis and acceleration channel research where its value is reached xxxxxxxx 1.

Step 3: where it has reached 1. XXXXXXXX in the process of accelerating from this point in the channel 3 and 4, paste all the values STD. STD values in the attached excel file.

How can I do this? What is the formula or the script to do this?

Hi Rash.patel,

You didn't yet tell me where to find the Excel file, so I assumed it would be in the same folder as the VBScript script.  I used the DIAdem Excel Import Wizard to create an *.stp file that can be passed as parameter in the ExcelImport() command to load these curves 2 envelopes by program.  I also added a file dialog box, then you can select the *. DAT to deal with file.

I think that's

Tiara Product Support Engineer
National Instruments

• Replace the values in the channels, if a string has a model value

Version: Oracle 10g

Hi all, I have a need for which I am trying to write a proc.
I wanted to know if there is an another easier way to do this.

T_DATE and v_value will have an equal number of values
If the value T_DATE or v_value is = # remove this T_DATE value and the corresponding value
v_value (and vice versa)
``````Example 1:
-------------
v_date
:= 'August, 16, 2010~August, 16, 2010~September, 17, 2010~August, 16, 2010~###';
v_value   := '###~EFGH~IJKL~MNOP~QRST';

O/P required :
v_date := 'August, 16, 2010~September, 17, 2010~August, 16, 2010';
v_value   'EFGH~IJKL~MNOP';

Example 2
----------

v_date
:= 'August, 17, 2010~###~September, 19, 2010~###~August, 21, 2010';
v_value   := '###~EFGH~###~MNOP~###';

O/P required :
---------------
v_date := NULL;
v_value   NULL;``````
Thank you

Hello

new learner wrote:
Version: Oracle 10g

Hi all, I have a need for which I am trying to write a proc.
I wanted to know if there is an another easier way to do this.

Easier than what? Post what you're doing now.

It seems simple enough
Are T_DATE and v_value are IN OUT parameters?
(1) create new variable this_date, this_vlaue, new_date and new_value, NULL string initially.
(2) loop while T_DATE and v_value are not NULL.
(3) use INSTR to find date_pos, the position of the first delimiter in T_DATE.
(4) set this_date: = SUBSTR (T_DATE, date_pos, 1, -1) and then T_DATE: = SUBSTR (T_DATE, date_pos + 1). Watch out for the special case when you are at the last iitem, and there is no delimiter in v_pos.
(5) do the same thing with v_value, this_value, and new_value.
(6) If is neither this_date nor this_value ' #', concatenate them (with a delimiter, if necessary) to new_date and new_pos.
(7) repeat the loop.
(8) Finally, set T_DATE > = new_date and v_value: = new_value.

• Need to use values from the first query in other queris to the data model

Hello
Here is my requirement-

I use the data model to run multiple queries. The first query, I get 10 records. Now, I want to use these 10 records in the second query to get my final result. I am not able to use the sub query as the two motions are quite long and complex.

Select distinct Bishop of emp

Select empno, emp where Bishop in (: Bishop)

I can't use: Bishop because it will give only the last value stored at Archbishop. Is it possible to be able to use all the values from the first query in the second query using the data model?

Hello

Are you sure that you have your "dataStructure" configured correctly? Try this simple example:

```
```

Hope this helps

Andy

• Dashboard invites using values of the table no

Hello

I have a requirement of the customer to design a report to dashboard as follows.

Guest of dashboard will have 4 filters, three filters comes from the table, but the fourth filter has 3 values of the table no. The fourth filter will have values like 'Report with Sales Amount', 'Report with the purchase amount', 'report with purchases and sales '. I have three different reports of Table designed for each of the fourth filter choices. But how I apply, also in line of dashboard and navigate through the rite based on the selection report.

My approach is correct.

The fourth guest where you 'Report with Sales Amount', 'Report with the purchase amount', 'Report with both purchase and sales' you shoot a dummy column in the command prompt and write a sql in show.

would be something like

SELECT Case when 1 = 0 then the 'Customer Dimension. " "" Cust name ' another 'report with Sales Amount' the end OF sales UNION SELECT Case when 1 = 0 then 'Customer Dimension. " "" Cust name ' another 'report with the amount of the purchase' end OF sale

and in the quick game, a variable presentation tell var_criteria

Now create report2 for a certain randomn column with another column has the values you want to display for example 'in relation to the amount of sales.
Create a filter on the 2nd column and reference the variable var_criteria of presentation and it by default "in relation to the amount of sales.

On the dashboard in the section page put the report and select navigatoin guided by selecting report 2.

Please let me know if you have any questions.

Thank you
deep

• using value of the element in the process of ondemand

All,

Ive ondemand treat like below to do simple insert when it is called, but its takes only not entered value point, but it works when hardcoded values is specified. Can someone help me find the issue here

application process:

===================

Start

insert into test1 values (117, 'Hello' - |) V ('P41_EMPID'));

HTP.p ('Hello world');

exception

while others then

HTP. PRN ("an error occurred retrieving the name");

end;

the value V ('P41_EMPID') or: P41_EMPID is blank in the table, what could be the problem?

Gor_Mahia wrote:

Ive ondemand treat like below to do simple insert when it is called, but its takes only not entered value point, but it works when hardcoded values is specified. Can someone help me find the issue here

application process:

===================

Start

insert into test1 values (117, 'Hello' - |) V ('P41_EMPID'));

HTP.p ('Hello world');

exception

while others then

HTP. PRN ("an error occurred retrieving the name");

end;

the value V ('P41_EMPID') or: P41_EMPID is blank in the table, what could be the problem?

The element has a value of session state when the process is run. How and when is the value of P41_EMPID together?

• Application function rounded to the whole of the channel

I have a channel in tiara with a large amount of values (36,000,000) contain the values on 13 decimals.

I would like to round the value to about 4 or 5 decimal places max.

Can someone help me understand how to do this in DIAdem.

Example:

0.3784729837492-> 0.37847

I want this for each value in the channel.

can someone help me understand how to do this?

Tom

From D-cubed method of work, but with 36,000,000 points given, it will take a lot of time.  Use the calculator.  Copy this function in the ECU for analysis, and it will happen almost instantly.  Replace the 3 by the desired number of decimal places.

Ch("/Channel") = Round (ch("/ChannelToBeRounded"), 3)

If you need a VB Script:

```Dim ChannelToRound, DecimalPoints
ChanneltoRound = "" / ChannelToBeRounded "  ' set the channel to round here"
DecimalPoints 6 =             ' specify the number of decimals
"This will create a new channel called"Channel"in Group 1 with the rounded values
```

• How to assign a value of the element from page to main page in the column element when Cre

I have a form build on table T1. The T1 has a primary key defined (T1PK) and four other columns (C1 - C4). I have a form in this table. This form accepts the values of C1 to C4 and displayis an extra point, is not based on columns of T1 - P1_DUMMY. The form for T1PK element has the value "hidden and protected.
When creating the form, I wanted that the value of the primary key (T1PK) will be obtained through existing trigger. I want to use the value stored in the page called "P1_DUMMY" for P1_T1PK.

No matter what I do, I always get this error when I hit the button 'CREATE' on the page of the form:

ORA-01400: cannot insert NULL into ('DEV'. "" T1 ". ("' T1PK")

The Create button is a condition not to show if the the P1_T1PK page element is NULL. I created page rendering process, the process of transformation of page like this bock of PL/SQL:

: P1_T1PK: =: P1_DUMMY

But I still get ORA-01400. The form has the P1_DUMMY as display only, not not to store the State, so I can see that the P1_DUMMY element has the value I want (2).

How to assign the value stored in P1_DUMMY in P1_T1PK when I click on the button CREATE on this form?

Daniel

Hello
The belief question is the way in which the calculation is being defined. You are not using the &. rating (dot ampersand) in PL/SQL and SQL.

Try this.

1 define the calculation on P1_T1PK of Type calculation of value of the element
2. on the next page to load textarea, enter P1_DUMMY. No. colon or &
3. give appropriate conditions

Kind regards

• Get the field to remain Virgin until the user enters the value in the previous field used in the calculation

I work on a PDF form and am stuck on one of my calculations. There are two fields 'desired Start Date", which is a date entered by the user. The "desired end" date is one year from date entered by the user. I figured out - however, before the user enters a date, I want this field remains empty. Currently, it fills with 01/00/000. How can I get this field to calculate not unless a date is entered by the user? So far, I tried this but can not get the blank to stay:

If the field 'Desired Start Date' is empty, leave 'to' field blank

var myStartDate = new Date (this.getField("Desired_Effective_Date").value);

If (((myStartDate == 0) & & (getField("myStartDate").valueAsString = "")) {event.value = "";})

If the field "Desired Start Date" is an effective date, use the date to calculate one year after the date of entry.

}

else {this.getField("to").value = util.printd ("mm/dd/yyyy", new Date (myStartDate.getFullYear () + 1, myStartDate.getMonth (), myStartDate.getDate ()))}

Try the following than the calculation script custom field "to".

Get the value of the date field beginning

var sStartDate = getField("Desired_Effective_Date").valueAsString;

If the start date field is not empty...

If {(sStartDate)

Converts a date in a date object string

Kai = util.scand ("mm/dd/yyyy", sStartDate);

oDate.setFullYear (oDate.getFullYear () + 1);

Set this field to the calculated date value

Event.Value = util.printd ("mm/dd/yyyy", anyway);

} else {}

This field blank because the input field is empty

Event.Value = "";

}

You may need to change the date format "mm/dd/yyyy", I used to match the formats of date fields.

• Using the calculation script to write the value of the variable Substitution in a file

Hello

I am trying to use the calculation script to write the value of Substitution variable in a text file.
I use the dataexport command. But it is not able to write values in the text file.

Any help is appreciated.

Thank you.

BTW, I mostly prefer Esscmd MaxL. I think that makes me a heretic, but I don't understand why I don't want to type more rather than less to get the same result.

Running a calc:
Esscmd - RUNCALC 2 calcname
MaxL - run calculation Sample.Basic.calcname;

To be fair, Esscmd requires a dbname appname SELECT before the RUNACALC, but it is always less striking.

However, time is running, so I don't have too. And of course, MaxL now has many things that Esscmd doesn't like Esscmd is obsolete.

I always use Esscmd to run scripts of calc I can actually watch the output in real time as opposed to MaxL that exports the console at the end of execution.

Kind regards

Cameron Lackpour

• Create a channel by combining smaller values of the other two channels

Hello, I have two channels (v + and Volts1 +) and I am trying to create another channel (Volts_Small) that will have smaller values of the two channels. I need to compare each data point in the two channels and add little value to the new channel.

THS is what I tried without success:

```I have Sun
Dim: Set Group = Data.Root.ChannelGroups ("200_68")
Dim Chn1: Set Chn1 = Group.Channels ("v +")
Dim Chn2: Set Chn2 = Group.Channels ("Volts1 +")
Dim Chn3: Set Chn3 = Group.Channels ("Volts_Small")
For i = 1 to Chn1.Size
If (Chn1.Values (i) > Chn2.Values (i)) then
Chn3.values (i) = Chn2.Values (i)
On the other
Chn3.values (i) = Chn1.Values (i)
End If
Next```

I would give much help appreciate with this! Thank you.

Cedric

EDIT:

Nevermind, I solved this problem:

```I have Sun
Dim: Set Group = Data.Root.ChannelGroups ("200_68")
Dim Chn1: Set Chn1 = Group.Channels ("v +")
Dim Chn2: Set Chn2 = Group.Channels ("Volts1 +")
Dim Chn3: Set Chn3 = Group.Channels ("Volts_Small")
For i = 1 to 900000
If (Chn1.Values (i) > Chn2.Values (i)) then
Chn3.values (i) = Chn2.Values (i)
On the other
Chn3.values (i) = Chn1.Values (i)
End If
Next```

Hi Cedric,

I strongly advise to use the calculator channel and the MinV() function that is already integrated to tiara.  You have less code that runs much faster, especially for the largest data sets.

```Dim: Set Group = Data.Root.ChannelGroups ("200_68")
Dim Chn1: Set Chn1 = Group.Channels ("v +")
Dim Chn2: Set Chn2 = Group.Channels ("Volts1 +")
Dim Chn3: Set Chn3 = Group.Channels ("Volts_Small")
Var Variables: Variables = Array ("Ch1", "Ch2", "Ch3")
Dim channels: channels = Array (Chn1, Chn2, Chn3)
Call to calculate ("Ch3 = MinV (Ch1, Ch2)", Variables, channels)```

Tiara Product Support Engineer

National Instruments

• I want to add values from the individual at the end of an existing channel

I have a program the calulates several values of my data and you want to write each one sequentialy in a new way that I created.  How to assign a value to the end of a string?

```Option Explicit
«OPTIONAL: channel automatically.» In this place it is possible to book before the start of the speed
chObj.ReservedSize = 1000
Call AppendValue (chObj, 1.0)
Call AppendValue (chObj, 2.0)
Call AppendValue (chObj, 3.0)
Call AppendValue (chObj, 4.0)
Call AppendValue (chObj, 5.0)
Void AppendValue (chObj, newVal)
chObj.Values (chObj.Size + 1) = newVal
End Sub```

Channel grows automatically. Remember that it might be useful to use the ReservedSize property if you can assume that the channel will be how long.

• read the independent values in a channel

Hello

I want to read the value of a chanel.

I guess that every chanel's store as an array with an index and a value.

I would like to read a value of a chanel with its index number, then do some calculations, and then write to it.

For example:

Chanel 1:
index value
1           1
2           1
3           1
4           2
5           1
6           1

start index = 0
value > 1?
If no control of the following
If so do something

Do you have a sample script to read a unique value in a chanel?

Kind regards

Frédéric MANUAL

OK, so it should work

Dim oChn, K, value
"Go to the channel you are interested in.
Set oChn = data. GetChannel ("Time")

' loop through all the values
For K = 1 To oChn.Size
Value = oChn (K)
If (value > 1) then
"do something
MsgBox ("value WG 1")
End If
Next

• Using the channel of the flaws with the reading of data

Is it possible to substitute a model output when I want real data playback using the stim profile editor?

I understand how to use the flaws of the stim profile editor to replace an unique to a single value output channel, but is there a way to "fault" of the channel to the data I read (.csv file)?

Don't know how I missed that...  Exactly what I was looking for.

Thank you
Matt

• calculation of the average value of the sorted data and polar route drawing

Hello

I did a VI that calculates the average value of the wind rotor/speed-ratio in the sections of 30 degrees (wind direction). He also called the polar plot of calculated data. Everything works, but I would like to make more detailed calculations and drawings, by increasing the resolution to 1 degree, or...

Problem is VI, I did, is not easy on a large scale. At the moment, I have 12 parallel structures of switch-box to calculate the average value and build the array function to collect data calculated for Polar plot to draw the image in real time. I know it's probably the worst way to do it, but since I have done a few things with LV, it was the only way I managed to do what I wanted.

Now, if I continue in same way to reach my goal, I have to create 360 Parallels switch-case structures... that are crazy.

Something like the calculation of the average of the table or matrix (zero/empty values should not be calculated on average) inside the loop or similar way would probably be the best solution.

So, polar plot drawing is not a problem, but creating a reasonalbe average metering system is. Any ideas?

I would also like to rotare northward to the top (0 deg), and degrees of increase in a clockwise direction on polar ground dial plate (as on the compass).

VI on the attachment. (simplified version of the complete system)

I have signals:

-Wind speed

-wind direction

-Rotor speed

I want to:

-calculate the average value of the speed of the wind / rotor - ratio in sections (5 degrees, 1 degree)

-Draw a polar path of the wind rotor/speed-ratio of averages in propotion of wind direction

I'm using LabView 2009

Thank you very much.

It is closer to what you're looking for?