# ---------------------------------------------------------------------- # LANGUAGE: MATLAB API # ====================================================================== # AUTHOR: Michael McLennan, Purdue University # Copyright (c) 2004-2012 HUBzero Foundation, LLC # # See the file "license.terms" for information on usage and # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. # ====================================================================== language "MATLAB" { extension ".m" command {matlab -nodisplay -r infile='@driver',path('@tool',path),@@FILEROOT@@} main {% ---------------------------------------------------------------------- % MAIN PROGRAM - generated by the Rappture Builder % ---------------------------------------------------------------------- % open the XML file containing the run parameters % the file name comes in from the command-line via variable 'infile' io = rpLib(infile); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Get input values from Rappture %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@INPUTS@@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Add your code here for the main body of your program %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % spit out progress messages as you go along... rpUtilsProgress(0, 'Starting...'); rpUtilsProgress(5, 'Loading data...'); rpUtilsProgress(50, 'Half-way there'); rpUtilsProgress(100, 'Done'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Save output values back to Rappture %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@OUTPUTS@@ rpLibResult(io); quit; } input boolean { code "\n% get input value for $path" code "str = rpLibGetString(io,'$path.current');" code "$id = strcmpi(str,'yes');" } input image { code "\n% get input value for $path" code "% returns base64-encoded image data" code "$id = rpLibGetString(io,'$path.current');" } input integer { code "\n% get input value for $path" code "$id = int32(rpLibGetDouble(io,'$path.current'));" } input number { set units [attr get units] if {$units ne ""} { code "\n% get input value for $path and convert to $units" code "str = rpLibGetString(io,'$path.current');" code "\[$id,err\] = rpUnitsConvertDbl(str, '$units');" } else { code "\n% get input value for $path" code "$id = rpLibGetDouble(io,'$path.current');" } } input * { code "\n% get input value for $path" code "$id = rpLibGetString(io,'$path.current');" } output curve { code "\n% save output value for $path" code "% this assumes a vector 'x' and a vector 'y'" code "xydata = \[x;y\];" code "str = sprintf('%12g %12g\\n', xydata);" code "rpLibPutString(io,'$path.component.xy',str,0);" } output histogram { code "\n% save output value for $path" code "% vectors x,h,w: x-coord, height of bar, and width of bar (optional)" code "xhwdata = \[x;h;w\];" code "str = sprintf('%12g %12g %12g\\n', xhwdata);" code "rpLibPutString(io,'$path.component.xhw',str,0);" } output image { code "\n% save output value for $path" code "% data should be base64-encoded image data" code "rpLibPutString(io,'$path.current',imdata,0);" } output integer { code "\n% save output value for $path" code "rpLibPutString(io,'$path.current',num2str($id),0);" } output number { code "\n% save output value for $path" code "rpLibPutString(io,'$path.current',num2str($id),0);" } output * { code "\n% save output value for $path" code "rpLibPutString(io,'$path.current',$id,0);" } }