Author |
Topic |
|
vkatsap
USA
Posts |
Posted - 06/12/2008 : 12:06:57 PM
|
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
|
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 |
|
|
vkatsap
USA
Posts |
Posted - 06/13/2008 : 08:41:13 AM
|
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
|
|
|
vkatsap
USA
Posts |
Posted - 06/13/2008 : 2:39:11 PM
|
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
|
|
|
easwar
USA
1964 Posts |
Posted - 06/13/2008 : 9:56:20 PM
|
[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
|
|
|
thomaspreuth
Switzerland
Posts |
Posted - 05/14/2009 : 04:38:43 AM
|
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? |
|
|
Deanna
China
Posts |
Posted - 05/18/2009 : 09:59:26 AM
|
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 |
|
|
|
Topic |
|
|
|