Changeset 1260 for trunk/examples


Ignore:
Timestamp:
Dec 20, 2008, 2:51:08 PM (16 years ago)
Author:
dkearney
Message:

updating octave and matlab example code to take advantage of vector operations to write data to rappture library object. this helps with large arrays, you no longer need to iterate over each element in the array and write elements one by one.

Location:
trunk/examples/app-fermi
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/app-fermi/matlab/compiled/fermi.m

    r1139 r1260  
    11% ----------------------------------------------------------------------
    2 %  EXAMPLE: Fermi-Dirac function in Matlab.
     2%  EXAMPLE: Fermi-Dirac function in Octave.
    33%
    44%  This script represents a newly written application with rappture
     
    88%  AUTHOR:  Michael McLennan, Purdue University
    99%  AUTHOR:  Derrick Kearney, Purdue University
    10 %  Copyright (c) 2004-2008  Purdue Research Foundation
     10%  Copyright (c) 2004-2007  Purdue Research Foundation
    1111%
    1212%  See the file "license.terms" for information on usage and
     
    1414% ======================================================================
    1515
    16 function retVal=fermi;
     16% get out input file from the command line
     17% invoke this script with the following command:
     18% matlab -nodisplay -r infile=\'driver1234.xml\',fermi
     19% the above command sets variable infile to the name 'driver1234.xml'
    1720
    18 % We open the xml file in the main function and make lib global
    19 global lib;
     21% infile = 'driver31619.xml'
     22
     23% open our xml input file.
     24lib = rpLib(infile);
    2025
    2126% retrieve user specified data out of the input file
     
    4146rpLibPutString(lib,'output.curve(f12).yaxis.units','eV',0);
    4247
    43 for j=1:200
    44   rpUtilsProgress((j/200*100),'Iterating');
    45   putStr = sprintf('%12g  %12g\n', f(j), E(j));
    46   % put the data into the xml file
    47   rpLibPutString(lib,'output.curve(f12).component.xy',putStr,1);
    48 end
     48% this is a slow and inefficient method of putting
     49% large amounts of data back in to the rappture library object
     50%for j=1:200
     51%  rpUtilsProgress((j/200*100),'Iterating');
     52%  putStr = sprintf('%12g  %12g\n', f(j), E(j));
     53%  % put the data into the xml file
     54%  rpLibPutString(lib,'output.curve(f12).component.xy',putStr,1);
     55%end
     56
     57% a better way is to take advantage of matlab's vector operations.
     58outData = [f;E];
     59putStr = sprintf('%12g  %12g\n', outData);
     60rpLibPutString(lib,'output.curve(f12).component.xy',putStr,0);
    4961
    5062% signal the end of processing
    5163rpLibResult(lib);
    5264
    53 retVal = 0;
     65quit;
  • trunk/examples/app-fermi/matlab/uncompiled/fermi.m

    r1222 r1260  
    4646rpLibPutString(lib,'output.curve(f12).yaxis.units','eV',0);
    4747
    48 for j=1:200
    49   rpUtilsProgress((j/200*100),'Iterating');
    50   putStr = sprintf('%12g  %12g\n', f(j), E(j));
    51   % put the data into the xml file
    52   rpLibPutString(lib,'output.curve(f12).component.xy',putStr,1);
    53 end
     48% this is a slow and inefficient method of putting
     49% large amounts of data back in to the rappture library object
     50%for j=1:200
     51%  rpUtilsProgress((j/200*100),'Iterating');
     52%  putStr = sprintf('%12g  %12g\n', f(j), E(j));
     53%  % put the data into the xml file
     54%  rpLibPutString(lib,'output.curve(f12).component.xy',putStr,1);
     55%end
     56
     57% a better way is to take advantage of matlab's vector operations.
     58outData = [f;E];
     59putStr = sprintf('%12g  %12g\n', outData);
     60rpLibPutString(lib,'output.curve(f12).component.xy',putStr,0);
    5461
    5562% signal the end of processing
  • trunk/examples/app-fermi/octave/fermi.m

    r665 r1260  
    4141rpLibPutString(lib,"output.curve(f12).yaxis.units","eV",0);
    4242
    43 for j=1:200
    44   rpUtilsProgress((j/200*100),'Iterating');
    45   putStr = sprintf('%12g  %12g\n', f(j), E(j));
    46   % put the data into the xml file
    47   rpLibPutString(lib,"output.curve(f12).component.xy",putStr,1);
    48 end
     43% this is a slow and inefficient method of putting
     44% large amounts of data back in to the rappture library object
     45%for j=1:200
     46%  rpUtilsProgress((j/200*100),'Iterating');
     47%  putStr = sprintf('%12g  %12g\n', f(j), E(j));
     48%  % put the data into the xml file
     49%  rpLibPutString(lib,"output.curve(f12).component.xy",putStr,1);
     50%end
     51
     52% a better way is to take advantage of octave's vector operations.
     53outData = [f;E];
     54putStr = sprintf('%12g  %12g\n', outData);
     55rpLibPutString(lib,'output.curve(f12).component.xy',putStr,0);
    4956
    5057% signal the end of processing
Note: See TracChangeset for help on using the changeset viewer.