Author |
Topic |
|
tanosca
Canada
Posts |
Posted - 09/27/2006 : 07:26:58 AM
|
Origin Version (Select Help-->About Origin): Operating System:
Labtalk Script
I am new to OriginLab, and I would like some help please on a simple if-else statement.
if Col(A) < 0 { Col(B) = 2+2; } else { Col(B) = 7; }
The above statement doesn't work at all. If I include a "For" statement, I get results, but not what I'm expecting. Origin seems to find the first condition of the "IF" (let's say a negative value) and applies that calculation to all elements in the dataset regardless of sign, it completely ignores the else. Can you assist please.
for (i=1; i <=4; i++)
if (Col(A) < 0 ) { Col(B)[i] = 2+2; } else { Col(B)[i] = 7; }
Thank you |
|
larry_lan
China
Posts |
Posted - 09/27/2006 : 07:40:25 AM
|
Hi:
the test condition should be included in the parentheses:
if (Col(A) < 0) { Col(B) = 2 + 2; }
In this case, the left value of the test condition is the first cell value of column A. So the above scripts equals to
if (Col(A)[1] < 0) { Col(B) = 2 + 2; }
Larry OriginLab Technical Services |
|
|
tanosca
Canada
Posts |
Posted - 10/02/2006 : 2:09:00 PM
|
Sorry for the delay in sending my thxs.
Hi:
the test condition should be included in the parentheses:
if (Col(A) < 0) { Col(B) = 2 + 2; }
In this case, the left value of the test condition is the first cell value of column A. So the above scripts equals to
if (Col(A)[1] < 0) { Col(B) = 2 + 2; }
Larry OriginLab Technical Services [/quote] |
|
|
merlin1401
1 Posts |
Posted - 11/16/2010 : 09:18:51 AM
|
I want to integrate the Heaviside-function into my fitting. It is compiled successfully but doesn't do the right thing. Who knows how to fix this problem? The source-code is the following:
#pragma warning(error : 15618) #include <origin.h> #include <math.h> #include <stdio.h>
void _nlsfDeconv_1(
double A, double x0, double y0, double t, double G,
double x,
double& y) { double z; double temp; temp = (y0+A*exp(G^2/(16*ln(2)*t^2))*exp(-(x-x0)/t)); if(x-x0<0.0){z==0.0;} else {z==1.0;}; y =z*temp; } |
|
|
|
Topic |
|
|
|