Is it possibe showing components during mutli-compon fitting

General forum for EasySpin: questions, how to's, etc.
Post Reply
weitong
Newbie
Posts: 3
Joined: Tue Oct 13, 2015 9:45 am

Is it possibe showing components during mutli-compon fitting

Post 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
fitting.PNG (102.87 KiB) Viewed 4743 times
Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Is it possibe showing components during mutli-compon fit

Post by Stefan Stoll »

Unfortunately, this is currently not possible.
thanasis
Local Expert
Posts: 242
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Is it possibe showing components during mutli-compon fit

Post 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...
Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Is it possibe showing components during mutli-compon fit

Post by Stefan Stoll »

I think you could use figure(234) and subplot to achieve this. Put each of the spectra in a separate subplot.
thanasis
Local Expert
Posts: 242
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Is it possibe showing components during mutli-compon fit

Post 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.
thanasis
Local Expert
Posts: 242
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Is it possibe showing components during mutli-compon fit

Post 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
Subcomponents window
Selection_030.png (90.11 KiB) Viewed 4045 times
Stefan Stoll
EasySpin Creator
Posts: 1050
Joined: Mon Jul 21, 2014 10:11 pm
Location: University of Washington

Re: Is it possibe showing components during mutli-compon fit

Post 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.
thanasis
Local Expert
Posts: 242
Joined: Thu Jan 21, 2016 6:28 am
Location: Strasbourg

Re: Is it possibe showing components during mutli-compon fit

Post 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!
Post Reply