Matlab engine through C++ - Avoid the opening of the graph

1 visualizzazione (ultimi 30 giorni)
Hi everyone,
I am using matlabe engine through my C++ code. my code is very simple and each time I run it it opens the graph from matlab, before saving it in a folder. Is there a way of telling matlab to not open the graph when it creates it ?
here is my matlab code
h(:,1)=one;
h(:,2)=two;
[y,x]=hist(h);
%NumBins = 10;
bar(x,y, 'group');
title('Area comparison');
xlabel('Area'); % x-axis label
ylabel('Frequency'); % y-axis label
%may do it as two variables passed through C++
legend('XZ','YZ');
saveas(gcf,mypath);
one, two, and mypath are variables given through C++. cheers, Flo

Risposta accettata

James Tursa
James Tursa il 5 Mag 2016
Modificato: James Tursa il 5 Mag 2016
Prior to calling the hist function, create the figure with the 'Visible' property set to 'Off'. E.g.,
f = figure('Visible','Off');
[y,x] = hist(h);
:
etc
If you subsequently want to see the plot, you can do this:
set(f,'Visible','On');
If you never want to see the plot with this code, then you don't need to save the gcf in the f variable.

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by