tomwalters@0: % method of class @parameter tomwalters@0: % tomwalters@0: % (c) 2003, University of Cambridge tomwalters@0: % Stefan Bleeck (stefan@bleeck.de) tomwalters@0: % http://www.mrc-cbu.cam.ac.uk/cnbh/aimmanual/tools/parameter tomwalters@0: % $Date: 2006-01-10 14:50:30 +0000 (Tue, 10 Jan 2006) $ tomwalters@0: function param=setas(param,text,value,unit,inbox) tomwalters@0: %% sets the parameter value in the parameter "text" in the panel "inbox" to tomwalters@0: %% the value "value". tomwalters@0: % param must be of type float or int tomwalters@0: tomwalters@0: if nargin<5 tomwalters@0: inbox='all'; tomwalters@0: end tomwalters@0: tomwalters@0: % cont=param.entries; tomwalters@0: nr=getentrynumberbytext(param,text,inbox); tomwalters@0: if nr>0 tomwalters@0: if isequal(value,'auto'); tomwalters@0: param.entries{nr}.rawvalue=value; tomwalters@0: param.entries{nr}.stringvalue=value; % set the string value tomwalters@0: else tomwalters@0: if ~ischar(value) tomwalters@0: unittype=param.entries{nr}.unittype; tomwalters@0: if ~isa(unittype,'unit_none') tomwalters@0: rawval=fromunits(unittype,value,unit); tomwalters@0: else tomwalters@0: rawval=value; tomwalters@0: end tomwalters@0: param.entries{nr}.rawvalue=rawval; % set the value in the class structure with the raw value tomwalters@0: param.entries{nr}.stringvalue=num2str(rawval); % set the string value tomwalters@0: else tomwalters@0: param.entries{nr}.stringvalue=value; % set the string value tomwalters@0: param.entries{nr}.rawvalue=str2num(value); tomwalters@0: end tomwalters@0: end tomwalters@0: if isfield(param.entries{nr},'handle') && ishandle(param.entries{nr}.handle{1}) % and set in the gui as well tomwalters@0: if strcmp(type,'float') tomwalters@0: hand=param.entries{nr}.handle{1}; tomwalters@0: if isequal(value,'auto'); tomwalters@0: set(hand,'String',value); % set the string as given tomwalters@0: else tomwalters@0: if ~ischar(value) tomwalters@0: if length(value)==1 tomwalters@0: set(hand,'String',num2str(value)); % translate to string tomwalters@0: else tomwalters@0: set(hand,'String',param.entries{nr}.stringvalue); % set the string as given tomwalters@0: end tomwalters@0: if ~isa(unittype,'unit_none') tomwalters@0: unitnr=findunit(unittype,unit); tomwalters@0: if length(param.entries{nr}.handle)>=2 && ishandle(param.entries{nr}.handle{2}) % and set in the gui as well tomwalters@0: set(param.entries{nr}.handle{2},'value',unitnr); % set the unit to the given one tomwalters@0: end tomwalters@0: end tomwalters@0: else % its a string format tomwalters@0: set(hand,'String',value); % set the string as given tomwalters@0: end tomwalters@0: end tomwalters@0: else tomwalters@0: sec=param.entries{nr}.slidereditcontrol; tomwalters@0: tomwalters@0: end tomwalters@0: return tomwalters@0: else tomwalters@0: error('setvalue::error, the entry does not exist'); tomwalters@0: end