tomwalters@0: % method of class @parameter tomwalters@0: % bleeck@3: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org 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 slider 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(param.entries{nr}.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: set(param.entries{nr}.handle{2},'value',unitnr); % set the unit to the given one 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 % it must be a slider tomwalters@0: secombi=param.entries{nr}.slidereditcombi; tomwalters@0: if ~isa(unittype,'unit_none') tomwalters@0: unitnr=findunit(unittype,unit); tomwalters@0: set(param.entries{nr}.handle{2},'value',unitnr); % set the unit to the given one tomwalters@0: editscaler=tounits(unittype,1,unit); tomwalters@0: secombi.editscaler=editscaler; tomwalters@0: end tomwalters@0: secombi=slidereditcontrol_set_raweditvalue(secombi,value); tomwalters@0: param.entries{nr}.slidereditcontrol=secombi; tomwalters@0: end tomwalters@0: return tomwalters@0: end tomwalters@0: else tomwalters@0: error('setvalue::error, the entry does not exist'); tomwalters@0: end