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
 Origin Forum
 How to normalize matrix?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

vkatsap

USA
Posts

Posted - 06/12/2008 :  12:06:57 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System: WinXp

I work with 256x256 numerical arrays, and transform them to matrices in Origin. I need to normalize matrix, and could not have done that within Set Matrix Values. Please help!

easwar

USA
1964 Posts

Posted - 06/12/2008 :  10:33:47 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You could run script such as below. You could then put such script in a custom/new toolbar button so you can just click that to run it on other matrices.


// Normalize to be between 0 and 1 in all cells
sum(%h);
[%h] -= sum.min;
[%h] /= (sum.max - sum.min);



In version 8, the matrix window can have more than one matrix sheet, and each matrix sheet can have more than one matrix object/array. So for O8, the code cannot use %h (window name), and need to refer to active matrix object like below:


range rm=<active>;
sum(rm);
rm -= sum.min;
rm /= (sum.max - sum.min);


Easwar
OriginLab


Edited by - easwar on 06/12/2008 11:09:54 PM
Go to Top of Page

vkatsap

USA
Posts

Posted - 06/13/2008 :  08:41:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Easwar, thanks for reply.
I tried your script, and it's zeroed my matrix. I think there's a slight misunderstanding here:

I need to normalize matrix to MAX value in array, so Matrix Set Values must do the following:

- find MAX cell value in 256x256 matrix;
-divide each cell value by this MAX value, and multiply it by 100 (as to convert into percentage)

could you please advise on this?

many thanks, Victor

quote:

Hi,

You could run script such as below. You could then put such script in a custom/new toolbar button so you can just click that to run it on other matrices.


// Normalize to be between 0 and 1 in all cells
sum(%h);
[%h] -= sum.min;
[%h] /= (sum.max - sum.min);



In version 8, the matrix window can have more than one matrix sheet, and each matrix sheet can have more than one matrix object/array. So for O8, the code cannot use %h (window name), and need to refer to active matrix object like below:


range rm=<active>;
sum(rm);
rm -= sum.min;
rm /= (sum.max - sum.min);


Easwar
OriginLab


Edited by - easwar on 06/12/2008 11:09:54 PM

Go to Top of Page

vkatsap

USA
Posts

Posted - 06/13/2008 :  2:39:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
thanka, I've got it running. Now that I have working Script window, how can I make a button out of it?
many thanks, Vic

quote:

Hi,

You could run script such as below. You could then put such script in a custom/new toolbar button so you can just click that to run it on other matrices.


// Normalize to be between 0 and 1 in all cells
sum(%h);
[%h] -= sum.min;
[%h] /= (sum.max - sum.min);



In version 8, the matrix window can have more than one matrix sheet, and each matrix sheet can have more than one matrix object/array. So for O8, the code cannot use %h (window name), and need to refer to active matrix object like below:


range rm=<active>;
sum(rm);
rm -= sum.min;
rm /= (sum.max - sum.min);


Easwar
OriginLab


Edited by - easwar on 06/12/2008 11:09:54 PM

Go to Top of Page

easwar

USA
1964 Posts

Posted - 06/13/2008 :  9:56:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
[quote]
Now that I have working Script window, how can I make a button out of it?
[quote]

Hi Vic,

Open programming help file in your 7.5 Origin (menu item Help->Programming) and look at the topic: Programming Guide->User-Interface Development->Toolbar Buttons

Easwar
OriginLab

Go to Top of Page

thomaspreuth

Switzerland
Posts

Posted - 05/14/2009 :  04:38:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry,
I still do not get it.
When i put your script into the set values window and let it run, nothing happens.

How exactly do you normalize the matrixes with its max value?
Go to Top of Page

Deanna

China
Posts

Posted - 05/18/2009 :  09:59:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Thomas,

Easwar's script was designed to be run in the Script Window/Command Window.

You can make your matrix active. Paste the following into the Command Window (If it is not open, select Window: Command Window from the ORigin menu):

range rm=<active>;sum(rm);rm -= sum.min;rm /= (sum.max - sum.min);


Press ENTER to execute the script.

Deanna
OriginLab Technical Services
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