how we remove GUI from this code without distrurbing the output of code..?

3 views (last 30 days)
This is the code
function y=spectroni2(low, high, interval)
load work
low=vecins(1);
high=vecins(2);
interval=vecins(3);
%çìåðåú è÷ñè ìäëðñú ðúåðéí
Hc_mix=uicontrol(gcf,'style','edit','backgroundcolor','white','units','normal','position',[0.05 0.05 0.08 0.05],'string','y3a10');
Hc_spectrumA=uicontrol(gcf,'style','edit','backgroundcolor','white','units','normal','position',[0.15 0.05 0.08 0.05],'string','cv');
Hc_spectrumB=uicontrol(gcf,'style','edit','backgroundcolor','white','units','normal','position',[0.25 0.05 0.08 0.05],'string','pen');
Hc_lowcut=uicontrol(gcf,'style','edit','string',low,'backgroundcolor','white','units','normal','position',[0.35 0.05 0.08 0.05]);
Hc_upcut=uicontrol(gcf,'style','edit','string',high,'backgroundcolor','white','units','normal','position',[0.45 0.05 0.08 0.05]);
%úååéåú ìçìåðåú ìäëðñú ðúåðéí
Hc_mixlable=uicontrol(gcf,'style','text','string','mixed spectrum','units','normal','position',[0.05 0.1 0.08 0.06]);
Hc_spectrumAlable=uicontrol(gcf,'style','text','string','spectrum A','units','normal','position',[0.15 0.1 0.08 0.06]);
Hc_spectrumBlable=uicontrol(gcf,'style','text','string','spectrum B','units','normal','position',[0.25 0.1 0.08 0.06]);
Hc_lowcutlable=uicontrol(gcf,'style','text','string','from wl','units','normal','position',[0.35 0.1 0.08 0.06]);
Hc_upcutlable=uicontrol(gcf,'style','text','string','to wl','units','normal','position',[0.45 0.1 0.08 0.06]);
%sliders
Hc_int=uicontrol(gcf,'style','slider','units','normal','position',[0.95 0.15 0.03 0.4],'min',-4,'max',-1,'value',-2);
Hc_minr=uicontrol(gcf,'style','slider','units','normal','position',[0.9 0.15 0.03 0.4],'min',-3,'max',0,'value',-2);
Hc_maxr=uicontrol(gcf,'style','slider','units','normal','position',[0.85 0.15 0.03 0.4],'min',0,'max',3,'value',2);
Hc_dis=uicontrol(gcf,'style','slider','units','normal','position',[0.8 0.15 0.03 0.4],'min',-4,'max',0,'value',0);
%slider lables
Hc_inta=uicontrol(gcf,'style','text','units','normal','position',[0.95 0.55 0.03 0.03],'string','int');
Hc_minra=uicontrol(gcf,'style','text','units','normal','position',[0.9 0.55 0.03 0.03],'string','minr');
Hc_maxra=uicontrol(gcf,'style','text','units','normal','position',[0.85 0.55 0.03 0.03],'string','maxr');
Hc_disa=uicontrol(gcf,'style','text','units','normal','position',[0.8 0.55 0.03 0.03],'string','dis');
%slider data
Hc_intlable=uicontrol(gcf,'style','text','units','normal','backgroundcolor','white','position',[0.95 0.1 0.06 0.03]);
Hc_minrlable=uicontrol(gcf,'style','text','units','normal','backgroundcolor','white','position',[0.9 0.1 0.03 0.03]);
Hc_maxrlable=uicontrol(gcf,'style','text','units','normal','backgroundcolor','white','position',[0.85 0.1 0.03 0.03]);
Hc_dislable=uicontrol(gcf,'style','text','units','normal','backgroundcolor','white','position',[0.8 0.1 0.03 0.03]);
Hc_minr10=uicontrol(gcf,'style','text','units','normal','backgroundcolor','white','position',[0.88 0.07 0.02 0.03],'string','10^');
Hc_maxr10=uicontrol(gcf,'style','text','units','normal','backgroundcolor','white','position',[0.83 0.07 0.02 0.03],'string','10^');
Hc_dis10=uicontrol(gcf,'style','text','units','normal','backgroundcolor','white','position',[0.78 0.07 0.02 0.03],'string','10^');
results={[1]};
results(1,1)={'name'};
results(1,2)={'spect A'};
results(1,3)={'spect B'};
results(1,4)={'maxOD A'};
results(1,5)={'wl'};
results(1,6)={'maxOD B'};
results(1,7)={'wl'};
results(1,8)={'RSQ'};
save results results;
%úáðéåú ìúåöàåú
Hc_frame1=uicontrol(gcf,'style','frame','units','normal','position',[0 0.9 0.1 0.05]);
Hc_frame2=uicontrol(gcf,'style','frame','units','normal','position',[0 0.85 0.1 0.05]);
Hc_frame3=uicontrol(gcf,'style','frame','units','normal','position',[0.1 0.9 0.1 0.05]);
Hc_frame4=uicontrol(gcf,'style','frame','units','normal','position',[0.1 0.85 0.1 0.05]);
Hc_frame5=uicontrol(gcf,'style','frame','units','normal','position',[0 0.8 0.1 0.05]);
%úååéåú ìúåöàåú
Hc_odmaxlable=uicontrol(gcf,'style','text','units','normal','position',[0 0.95 0.1 0.05],'string','OD_MAX');
Hc_odmaxlable=uicontrol(gcf,'style','text','units','normal','position',[0.1 0.95 0.1 0.05],'string','wl');
Hc_Alable=uicontrol(gcf,'style','text','units','normal','position',[0.2 0.9 0.1 0.05],'string','spectrum A');
Hc_Blable=uicontrol(gcf,'style','text','units','normal','position',[0.2 0.85 0.1 0.05],'string','spectrum B');
Hc_rmslable=uicontrol(gcf,'style','text','units','normal','position',[0.1 0.8 0.1 0.05],'string','RSQ');
%ëôúåø ìäåöàä îìåìàú äëðñú äðúåðéí
Hc_run=uicontrol(gcf,'style','radiobutton','string','run','units','normal','position',[0.9 0.9 0.1 0.1]);
Hc_close=uicontrol(gcf,'style','radiobutton','string','close','units','normal','position',[0.6 0.9 0.1 0.1]);
%ëôúåø ìòãëåï ðúåðé äîëùéø
while get(Hc_close,'value')==0;% ìåìàä ùìà ðâîøú
while get(Hc_run,'value')==0 & get(Hc_close,'value')==0
minr=10^get(Hc_minr,'value');
maxr=10^get(Hc_maxr,'value');
int=fix(10000*(1+10^get(Hc_int,'value')))/10000;
logdis=get(Hc_dis,'value');
pause(0.1)
set(Hc_intlable,'string',eval('int'));
set(Hc_minrlable,'string',eval('fix(100*log10(minr))/100'));
set(Hc_maxrlable,'string',eval('fix(100*log10(maxr))/100'));
set(Hc_dislable,'string',eval('(logdis)'));
end
%äôéëú ñîìé äëúá ìôøîèøéí ùì è÷ñè
smix=abs(get(Hc_mix,'string'));
spectA=abs(get(Hc_spectrumA,'string'));
spectB=abs(get(Hc_spectrumB,'string'));
dis=10^logdis;
%äôéëú ñîìé äëúá ìéöåâ ùì îñôøéí åå÷èåøéí
xy=eval(get(Hc_mix,'string'));
xx=eval(get(Hc_spectrumA,'string'));
yy=eval(get(Hc_spectrumB,'string'));
c=(eval(get(Hc_lowcut,'string'))-low)/interval+1;
l=(eval(get(Hc_upcut,'string'))-low)/interval+1;
if length(xy(1,:))==1;
xy=xy';
end
if length(xx(1,:))==1;
xx=xx';
end
if length(yy(1,:))==1;
yy=yy';
end
wl=(low:interval:high);%äâãøú åå÷èåø àåøëé âì
%÷éöåõ äåå÷èåøéí ìèååç ùð÷áò
xy=xy(c:l);
xx=xx(c:l);
yy=yy(c:l);
wl=wl(c:l);
xx=xx/max(xx);
yy=yy/max(yy);
%çéùåá
%çéùåá îñ' ä÷ôéöåú ùéùðï áéï òøê äîéðéîåí åäî÷ñéîåí áàéðèøååì ùð÷áò
n=ceil(log10(maxr/minr)/log10(int));
%ðéøîåì äåå÷èåø äîòåøá
xys=xy./max(xy);
%äâãøú åå÷èåø ääôøùéí
f=ones(1,n);
for k=1:1:n;
ratio=minr*int^k;
dd=ratio*xx+yy;
dds=dd/max(dd);
delta=(abs(xys-dds));
f(k)=sum(delta.^dis);
end
t=find_min(f);%îöéàú ð÷åãú äîéðéîåí áåå÷èåø ääôøùéí
spectrum_ratio=minr*int^t;%çéùåá äëåôì îîé÷åîå áåå÷èåø ääôøùéí
%áøéøú îçãì ìàéôåñ äåå÷èåø ëàùø äéçñ ðîåê îäîéðéîåí ùäåâãø
if spectrum_ratio>maxr;
yy=yy*0;
xx=max(xy)/max(xx)*xx;
elseif spectrum_ratio==minr*int;
xx=xx*0;
yy=max(xy)/max(yy)*yy;
elseif spectrum_ratio<=maxr & spectrum_ratio>minr ;
dd=spectrum_ratio*xx+yy;
yy_scalar=max(xy)/max(dd);
xx_scalar=yy_scalar*spectrum_ratio;
yy=yy_scalar*yy;
xx=xx_scalar*xx;
end
mxx=max(xx);
Amaxwl=find_max(xx)*interval+eval(get(Hc_lowcut,'string'))-interval;
myy=max(yy);
Bmaxwl=find_max(yy)*interval+eval(get(Hc_lowcut,'string'))-interval;
myy=max(yy);
cal=xx+yy;
rms=((sum(cal-xy).^2)/(l-c))^.5;
R=RSQ(cal,xy);
%ùîéøú úåöàåú
%load results;
sv=size(results);
shoorot=sv(1);
char(smix);
results(shoorot+1,1)={char(smix)};
results(shoorot+1,2)={char(spectA)};
results(shoorot+1,3)={char(spectB)};
results(shoorot+1,4)={mxx};
results(shoorot+1,5)={Amaxwl};
results(shoorot+1,6)={myy};
results(shoorot+1,7)={Bmaxwl};
results(shoorot+1,8)={R};
results
save results results
%úåöàåú
Hc_Amaxlable=uicontrol(gcf,'style','text','units','normal','position',[0.001 0.905 0.09 0.03],'string',eval('mxx'));
Hc_Bmaxlable=uicontrol(gcf,'style','text','units','normal','position',[0.001 0.855 0.09 0.03],'string',eval('myy'));
Hc_Amaxwllable=uicontrol(gcf,'style','text','units','normal','position',[0.101 0.905 0.09 0.03],'string',eval('Amaxwl'));
Hc_Bmaxwllable=uicontrol(gcf,'style','text','units','normal','position',[0.101 0.855 0.09 0.03],'string',eval('Bmaxwl'));
Hc_rms=uicontrol(gcf,'style','text','units','normal','position',[0.001 0.805 0.09 0.03],'string',eval('R'));
Hc_Alable=uicontrol(gcf,'style','text','units','normal','position',[0.2 0.9 0.1 0.05],'string',get(Hc_spectrumA,'string'));
Hc_Blable=uicontrol(gcf,'style','text','units','normal','position',[0.2 0.85 0.1 0.05],'string',get(Hc_spectrumB,'string'));
%éöéøú äâøó åäî÷øà
subplot('position',[0.05 0.2 0.7 0.6])
plot(wl,xy,'g:',wl,cal,'r.',wl,xx,'b',wl,yy,'m');
grid on;
legend('original','calculated',get(Hc_spectrumA,'string'),get(Hc_spectrumB,'string'));
Hc_run=uicontrol(gcf,'style','radiobutton','string','run','units','normal','position',[0.9 0.9 0.1 0.1]);
end
close
results(1:shoorot,:)
uicontrol command is related to GUI part I wanted to remove this GUI part without affected the output. my strategy is to remove this GUI part 1.find out the GUI command 2.find out that GUI command is returning some value or not.. 3. replace that uicommand by that value.. I used this approach but facing many difficulty . is any other approach to remove this GUI code.? please help me thanks.

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!