Path: news.mathworks.com!not-for-mail
From: "David Doria" <daviddoria@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Sample Matlab Engine Doesn't Work?
Date: Wed, 12 Mar 2008 21:39:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 24
Message-ID: <fr9ihp$nfk$1@fred.mathworks.com>
Reply-To: "David Doria" <daviddoria@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1205357945 24052 172.30.248.35 (12 Mar 2008 21:39:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 12 Mar 2008 21:39:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1105197
Xref: news.mathworks.com comp.soft-sys.matlab:456910



I tried this in c++, but it produces a blank plot!  I linked
to libmx.lib libmex.lib libeng.lib.

Seems very odd, it is clearly almost working because it is
producing a plot, but there is nothing on it!!
Any thoughts?

int main()
{
	Engine *ep;
	
	if (!(ep = engOpen("\0"))) {
		fprintf(stderr, "\nCan't start MATLAB engine\n");
		Pause();
		return EXIT_FAILURE;
	}
	engEvalString(ep, "x = 1:1:10);");
	engEvalString(ep, "y = x.^2;");
	engEvalString(ep, "plot(x,y);");
	engEvalString(ep, "title('Test');");
	Pause();

	//Free memory, close MATLAB engine.
	engEvalString(ep, "close;");