Page 1 of 1
Is it possibe showing components during mutli-compon fitting
Posted: Tue Oct 13, 2015 10:35 am
by weitong
I am wondering if it is possibe showing every component during fitting.
OR,can users have the option to choose showing any of the multi-components after fitting stopped.
- fitting.PNG (102.87 KiB) Viewed 6632 times
Re: Is it possibe showing components during mutli-compon fit
Posted: Wed Oct 14, 2015 1:42 pm
by Stefan Stoll
Unfortunately, this is currently not possible.
Re: Is it possibe showing components during mutli-compon fit
Posted: Sun Aug 07, 2016 2:13 pm
by thanasis
One workaround I have found is to write a very simple custom function which esfit will invoke. All it does is to plot one of the two systems. The selection is done depending their distinguishing characteristics:
Code: Select all
function [x,y] = decompose(Sys,Exp,Opt)
if Sys.g(1,2)>=2.32
[x,y] = pepper(Sys,Exp,Opt);
plot(x,y);
elseif Sys.g(1,2)<2.32
[x,y] = pepper(Sys,Exp,Opt);
end
end
This will plot the contribution of the system with g>=2.3 in a separate Matlab Figure window. Unfortunately, I haven't found a way to export two plots (pasting the same command in both places only returns one output).
However, it is better than nothing...
Re: Is it possibe showing components during mutli-compon fit
Posted: Fri Sep 09, 2016 12:32 am
by Stefan Stoll
I think you could use figure(234)
and subplot
to achieve this. Put each of the spectra in a separate subplot.
Re: Is it possibe showing components during mutli-compon fit
Posted: Wed Sep 14, 2016 2:26 am
by thanasis
I modified the code to:
Code: Select all
function [x,y] = decompose(Sys,Exp,Opt)
if Sys.g(1,2)>=2.32
[x,y] = pepper(Sys,Exp,Opt);
monomer=y' ; save('monomer','monomer','-ascii');
subplot(2,1,1);
plot(x,y)
elseif Sys.g(1,2)<2.32
[x,y] = pepper(Sys,Exp,Opt);
subplot(2,1,2);
plot(x,y)
trimer=y' ; save('trimer','trimer','-ascii');
end
end
and I do get a nice panel with the two plots, but only
after the calculation.
I must confess that did not understand the
figure(234)
command. Is is something like
figure(h)
as mentioned in Matlab manuals?
I tried to insert a
figure
command at the beginning of the script, but I got a whole bunch of figures
after the end of the calculation.
Re: Is it possibe showing components during mutli-compon fit
Posted: Wed Sep 14, 2016 3:14 am
by thanasis
Correction:
The previous code worked excellently, giving a panel with the two components changing in real time during the fit, but only when the fit was invoked through the GUI with
esfit('decompose',spc,{Sys1,Sys2},{Vary1,Vary2},Exp,[],FitOpt);
.
It did not work well when it was invoked so that the output was saved to an ascii, through:
[BestSys,BestSpc] = esfit('decompose',spc,{Sys1,Sys2},{Vary1,Vary2},Exp,[],FitOpt);
.
Still it is a good progress.
- Subcomponents window
- Selection_030.png (90.11 KiB) Viewed 5934 times
Re: Is it possibe showing components during mutli-compon fit
Posted: Wed Sep 14, 2016 8:14 am
by Stefan Stoll
The command figure(234)
activates figure no 234, or creates it if not already created. This makes Matlab plot in the same window when called repeatedly. You might need to issue drawnow
after the plot commands, to force Matlab to do the plotting. Otherwise, Matlab tries to be smart and plot only at the overall end of the calculation.
Re: Is it possibe showing components during mutli-compon fit
Posted: Thu Sep 15, 2016 4:35 am
by thanasis
Yes, that did it:
Code: Select all
function [x,y] = decompose(Sys,Exp,Opt)
figure(234)
if Sys.g(1,2)>=2.32
[x,y] = pepper(Sys,Exp,Opt);
monomer=y' ; save('monomer','monomer','-ascii');
subplot(2,1,1)
plot(x,y)
drawnow
elseif Sys.g(1,2)<2.32
[x,y] = pepper(Sys,Exp,Opt);
trimer=y' ; save('trimer','trimer','-ascii');
subplot(2,1,2)
plot(x,y)
drawnow
end
end
Now it works also without the GUI fitting option!