Author |
Topic  |
|
belmore
USA
Posts |
Posted - 02/11/2008 : 4:16:57 PM
|
Origin Version 7.5 Operating System: Windows
Data is for visible light absorption spectra collected at different applied electrical potentials (mV). Data is arranged as wavelength (x-column), mV (y-columns, first row) and absorption (y-columns). The mV data is not uniformly spaced. Example: Wavelength(x) Abs(y) Abs(y) Abs(y) Abs(y) Abs(y)
-- 317 175 164 143 119 800 0.001 0.001 0.000 0.001 0.000 700 0.101 0.154 0.235 0.385 0.033 600 0.152 0.384 0.762 1.121 1.081
How can I convert this to a matrix and 3D plot with wavelength as x-axis, mV as y-axis, and absorption values on the z-axis?
Thank You Brad |
|
greg
USA
1379 Posts |
Posted - 02/12/2008 : 09:49:14 AM
|
What you have is data in a matrix form with non-linear mapping parameters (at least non-linear across columns). Unfortunately, while a tool available in File Exchange has script to do that, Origin still does not have a routine to convert this kind of data to a matrix.
Here is the code that converts this kind of data to an XYZ worksheet. Once you have the XYZ, then you can use Random Gridding to get your matrix. Warning: Code is destructive, so work with a duplicate if you need the original data. // BEGIN SCRIPT // First column from row two is X (or Y) and // First row from column two is Y (or X) // (the reverse case can be covered by swapping X and Y afterward) get wcol(1) -e last; last-=1; wks.col=2; wks.insert(NewData); wo -a 1; tempcol=wks.ncols; copy -b 2 wcol(1) wcol(tempcol) -b 2 -e $(last+1); wo -a 1; // Worksheet columns: first NewData data data ... data tempcol tempy copy wcol(1) wcol(tempcol); // copy first column set wcol(tempcol) -e $(last+1); for(col=3;col<tempcol;col++) { // extract steps from row 1 wcol(wks.ncols)[col-1]=wcol(col)[1]; } mark -d wcol(1) -b 1 -e 1; for(col=4;col<tempcol;col++) { copy -a wcol(tempcol) wcol(1); // append to first doc -uw; copy -a wcol(col) wcol(3); // append to data }; for(col=4;col<=tempcol;col++) { delete wcol(4); }; numgrp=tempcol-3; for(n=1,thisrow=1;n<=numgrp;n++,thisrow+=last) { set wcol(2) -b thisrow;set wcol(2) -e thisrow+last-1;wcol(2)=wcol(4)[n];doc -uw; } set wcol(2) -b 1; delete wcol(4); wks.col3.name$=ZData; wks.col3.type=6; doc -uw; // END SCRIPT
To execute: Copy and paste the code to the Script Window (under Window menu) With your worksheet active, highlight all code and press Enter Select the C(Z) column and choose Edit : Convert to Matrix : Random
|
 |
|
|
Topic  |
|
|
|