How do I add a handles.axes figure into a HTML report programatically?

1 visualizzazione (ultimi 30 giorni)
I have a plot in a GUIDE gui, I want the user to click a button and grab the data and plot from the GUI and put it in an HTML report. The data part is simple and working, but getting the handles.axes1 plot to output to HTML I get this.... [1x1 matlab.graphics.axis.Axes]. Something like...
figure = axes(handles.axes1)
add(sec1,figure)
I don't want to run the analysis again because I know the handles object still exists.
How do I get report generator to take a snapshot of this figure?
I've realized working with GUIDE it doesn't display any variables in the workspace, this makes using report generator difficult when I have to look through code. And the interactive method isn't a promising solution if I can't do it programatically to begin with, so I need a solution done programatically.

Risposte (1)

Zacyatta
Zacyatta il 8 Apr 2018
Modificato: Zacyatta il 9 Apr 2018
As a short term solution, I used the handles object via handles.xdata and handles.ydata to pass my data to another callback and run the analysis again when adding the charts to a report.
%%Assay Plot
f = figure;
%%Fit: 'Parallel Line Plot'.
[xData, yData] = prepareCurveData( handles.logdataUnitsmL, handles.Standard );
% Set up fittype and options.
ft = fittype( 'poly1' );
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft )
stdcoeff = coeffvalues(fitresult)
stdRsquare = gof.rsquare
% Plot fit with data.
plot( fitresult,'-r', xData, yData , '.r');
a = get(gca,'Children')
hold on
%Second Plot
[xData, yData] = prepareCurveData( handles.logdataUnitsmL, handles.Test );
% Set up fittype and options.
ft = fittype( 'poly1' );
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft )
testcoeff = coeffvalues(fitresult)
testRsquare = gof.rsquare
% Plot fit with data.
plot(fitresult, '-b',xData, yData,'.b');
b = get(gca,'Children')
hold on
h = [a;b]
title('Heparin Sodium Parallel Line Assay')
legend(h, 'Standard Regression','Standard Assays', 'Test Regression', 'Test Assays', 'Location', 'NorthEast' );
% Label axes
xlabel('ln Units/mL')
ylabel('Absorbance')
grid on
fig = Figure(f)
add(sec1,fig)
%other chapters and sections here...
add(rpt,ch1)
close(f)
I prefer not doing this; however, I haven't found a way of passing the handles.axes object from the GUIDE. If someone has a solution I would like to know and accept a better answer!
Also, I found that setting the figure to and object "f" allows the figure to added to the report, and closed after the chapter is added to the report. Closing the figure after adding the section will result in error.
  1 Commento
Paul Kinnucan
Paul Kinnucan il 16 Apr 2018
A Figure reporter creates an image file of a figure and adds the image file to a report. The Figure reporter cannot do this until it is itself added to the report. In your case, the Figure reporter (fig) is not added to the report (rpt) until the section containing it (sect1) is added to the report. That is why an error occurs if you delete the figure (f) before adding sect1 to the report. In particular, the error occurs because the Figure reporter cannot generate an image from a figure that no longer exists.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by