T O P I C R E V I E W |
dominik.mierzwa |
Posted - 02/16/2021 : 11:59:36 AM Hi, I measured three parameters for two materials (C and D). I organized it in the indexed sheet and would like to calculate the formula: dE=sqrt((a2-a1)^2+(b2-b1)^2+(c2-c1)^2) where a2, b2, and c2 are mean for raw material C (raw_C) or D (raw_D), and a1, b1, and c1 are measurements for treated material (VI50_C, VI300_C, VI50_D and VI300_D). I would like to calculate dE for each row (except raw_C and raw_D). What is important the dE should be calculated with a proper mean value of a2, b2, and c2. I think that I need to use the “If…else” loop but I cannot solve this. Is there any way to do this with labtalk?
https://my.originlab.com/ftp/forum_and_kbase/Images/example%20data.opju
Kind regards, Dominik |
5 L A T E S T R E P L I E S (Newest First) |
snowli |
Posted - 02/17/2021 : 11:08:21 AM Sorry that I didn't explain that. Yes. We support wildcard in condition which makes the condition easier. Also you can define variables in Before Formula Script and use them in formula. This way the formula is easier.
Great to know it works.
Thanks, Snow |
dominik.mierzwa |
Posted - 02/17/2021 : 09:53:14 AM Works perfectly! Thank you! The point I stopped at was "A$=="V*C" Now, I know how to do this.
Kind regards, Dominik |
snowli |
Posted - 02/16/2021 : 2:21:49 PM We also have if(condition, true_expression, false expression ) originlab.com/doc/LabTalk/ref/If-func
E.g. try to put the following in dE's formula and before formula script boxes respectively and see if it's what you want
if(A$=="V*C", sqrt((a2c-B)^2+(b2c-C)^2+(c2c-D)^2), if(A$=="V*D", sqrt((a2d-B)^2+(b2d-C)^2+(c2d-D)^2), --))
double a2c=averageif(col(B), "col(A)$=="raw_C""); double b2c=averageif(col(C), "col(A)$=="raw_C""); double c2c=averageif(col(D), "col(A)$=="raw_C""); double a2d=averageif(col(B), "col(A)$=="raw_D""); double b2d=averageif(col(C), "col(A)$=="raw_D""); double c2d=averageif(col(D), "col(A)$=="raw_D"");
Thanks, Snow |
dominik.mierzwa |
Posted - 02/16/2021 : 12:50:05 PM quote: Originally posted by snowli
Hello,
Your question isn't clear. " a1, b1, and c1 are measurements for treated material (VI50_C, VI300_C, VI50_D and VI300_D)".
Thanks, Snow
Hi,
thank you for the fast reply. Well, averageif solve problem partially. Firstly, to calculate dE I need average value of a, b and c for raw_C and raw_D. Next for each row different from raw_C and raw_D I would like to calculate dE in accordance with the previously defined formula.
Now, for each row: If in col(A) name "VI50_C" or "VI300_C" is present then Origin should use the average of raw_C as (a2, b2 and c2) If in col(A) name "VI50_D" or "VI300_D" is present then Origin should use the average of raw_D as (a2, b2 and c2) If in col(A) is "raw_C or "raw_D" Origin should leave it or fill with ""
Kind regards, Dominik |
snowli |
Posted - 02/16/2021 : 12:25:24 PM Hello,
We have averageif() function to calculate averages with some condition met. https://www.originlab.com/doc/LabTalk/ref/Averageif-func
E.g. averageif(B, "col(A)$="raw_C"") will calculate a2 for you.
Your question isn't clear. " a1, b1, and c1 are measurements for treated material (VI50_C, VI300_C, VI50_D and VI300_D)".
But i think averageif() is what you are looking for to calculate a1, a2, b1, b2, .... and then u can calculate dE
Thanks, Snow |
|
|