The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 If-else Statement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

tanosca

Canada
Posts

Posted - 09/27/2006 :  07:26:58 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

tanosca

Canada
Posts

Posted - 10/02/2006 :  2:09:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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]
Go to Top of Page

merlin1401

1 Posts

Posted - 11/16/2010 :  09:18:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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;
}
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000