Writing a MATLAB plot to Excel as part of a loop?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm wondering if there's an easy-ish way to write the plot that I'm generating from fitnlm to an excel file that I'm already writing a few things to. I've seen some other solutions that involve using ActiveX control, but ActiveX seems pretty complicated and I don't know how to make AcX controls jive with what I currently have, which is:
clear all
for i = 1:2 %increments files
for j = 1:4 %increments sheets
sheet = j; %assigns sheet names
bob = sprintf('File%d.xlsx',i);
jane = sprintf('Output%d.xlsx',i);
matrix = xlsread(bob,sheet); %reads from sheet
nm = matrix(:,1);
I = matrix(:,2);
nI = I-min(I);
gauss = @(p,nm) p(1).*exp((-1*(nm-p(2)).^2)./((2*p(3).^2)));
guess2 = [100000 570 1];
g = fitnlm(nm,nI,gauss,guess2);
ng = feval(g,nm);
plot(nm, nI, '-', nm, ng, 'x');
beta = g.Coefficients.Estimate;
nmmax = beta(2);
intensity = beta(1);
Iter = {'N1', 'N2', 'N3', 'N4'}';
Head = {'Lambda Max', 'Max Intensity'};
cellB = sprintf('B%d:B%d',j+1,j+1);
cellC = sprintf('C%d:C%d',j+1,j+1);
xlswrite(jane,Head,'B1:C1'); %prints column headers
xlswrite(jane,Iter,'A2:A5'); %prints row labels
xlswrite(jane,nmmax,cellB); %prints lambda max
xlswrite(jane,intensity,cellC); %prints maximum intensity
end
end
I know to copy the plot to the clipboard, is there no straightforward way to copy that as a filetype and insert it into the same excel doc under my other stuff? Thanks a lot.
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Use COM Objects in MATLAB finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!