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
 All Forums
 Origin Forum
 Origin Forum
 Fitting

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
navid.solati Posted - 02/05/2018 : 02:27:14 AM
Origin Ver. and Service Release (Select Help-->About Origin):
Operating System:
Hello,
I have a script which finds the maximum point in a spectrum and put it in a matrix. Since there are more than 6000 data in each set, it opens files, reads them and after putting the result in the matrix it closes the file and goes to the next one. Now I would like to get the position (X value) of those maximum points. Could you please let me know how I can change the script so that I can reach my goal?

//Point to where the data files are

string path$ = "C:...";

findfiles ext:="*.txt"; // Find all files with wild card

int numFiles = fname.GetNumTokens(LF); // get number of files

int nFirst = 1;

//new matrixbook with 100*100 dimension

newbook mat:=1;

matrix -ps DIM 81 81;

range rr=1; //define a range for the first sheet of matrix

//loop over all files

for(int ifile = 1; ifile <= numFiles; ifile++)

{

newbook;

string filepath$;

// Get next file name

filepath$=fname.gettoken(ifile,LF)$;

// Parse out just file name without path and without extension

impasc fname:=filepath$
options.PartImp.Partial:= 1
options.PartImp.FirstRow:= 365
options.PartImp.LastRow:= 674;
filepath$=;

rr[$(ifile)]=max(col(B)); // get the maximum value for col(2) and put it to matrix cell.;

win -cd; //delete current workbook.

}

4   L A T E S T    R E P L I E S    (Newest First)
Castiel Posted - 02/08/2018 : 09:48:15 AM
quote:
Originally posted by navid.solati

I just realized the sum function is not what I am looking for. My data is in two columns, one is the x axis and the other is the y axis. I need to find X value for the Max Y value. As you can see in my first message, I have a code to find the Max of Y but I don't know how to find it's X value.



https://www.originlab.com/doc/LabTalk/ref/Sum-obj


     #####
    #### _\_  ________
    ##=-[.].]| \      
    #(    _\ |  |------|
     #   __| |  ||||||||
      \  _/  |  ||||||||
   .--'--'-. |  | ____ |
  / __      `|__|[o__o]|
_(____nm_______ /____\____ 
navid.solati Posted - 02/08/2018 : 09:00:53 AM
I just realized the sum function is not what I am looking for. My data is in two columns, one is the x axis and the other is the y axis. I need to find X value for the Max Y value. As you can see in my first message, I have a code to find the Max of Y but I don't know how to find it's X value.
navid.solati Posted - 02/08/2018 : 03:10:54 AM
Thank you castiel,

I tried to use sum(col(b)) but it is not working and I am getting an error saying "imaxval" is an unknown function!!
Castiel Posted - 02/05/2018 : 02:52:22 AM
quote:
Originally posted by navid.solati


rr[$(ifile)]=max(col(B)); // get the maximum value for col(2) and put it to matrix cell.;



Use sum() instead of max()
sum(col(B));
maxval = sum.max; // equivalent to max(col(B))
imaxval = sum.imax;  // index of max value



     #####
    #### _\_  ________
    ##=-[.].]| \      
    #(    _\ |  |------|
     #   __| |  ||||||||
      \  _/  |  ||||||||
   .--'--'-. |  | ____ |
  / __      `|__|[o__o]|
_(____nm_______ /____\____ 

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000