Home > vbmeg > external > iso2mesh > getvarfrom.m

getvarfrom

PURPOSE ^

SYNOPSIS ^

function p=getvarfrom(ws,name)

DESCRIPTION ^

 p=getvarfrom(ws,name)

 get variable value by name from specified work-space

 author: Qianqian Fang, <q.fang at neu.edu>

 input:
    ws: name of the work-space, for example, 'base'
    name: name string of the variable

 output:
    p: the value of the specified variable, if the variable does not
       exist, return empty array

 -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function p=getvarfrom(ws,name)
0002 %
0003 % p=getvarfrom(ws,name)
0004 %
0005 % get variable value by name from specified work-space
0006 %
0007 % author: Qianqian Fang, <q.fang at neu.edu>
0008 %
0009 % input:
0010 %    ws: name of the work-space, for example, 'base'
0011 %    name: name string of the variable
0012 %
0013 % output:
0014 %    p: the value of the specified variable, if the variable does not
0015 %       exist, return empty array
0016 %
0017 % -- this function is part of iso2mesh toolbox (http://iso2mesh.sf.net)
0018 %
0019 
0020 wsname=ws;
0021 if(~iscell(ws))
0022    wsname=cell(1);
0023    wsname{1}=ws;
0024 end
0025 
0026 p=[];
0027 for i=1:length(wsname)
0028     isdefined=evalin(wsname{i},['exist(''' name ''')']);
0029     if(isdefined==1)
0030         p=evalin(wsname{i},name);
0031         break;
0032     end
0033 end

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005