Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7620763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:01:06+00:00 2026-05-31T04:01:06+00:00

I’m trying to send simple string commands to the Matlab engine. This is my

  • 0

I’m trying to send simple string commands to the Matlab engine.

This is my code (there is no Matlab API related code anywhere else in my code, except for the #include "engine.h" line):

void MatlabPlotter::DrawInMatlab() const
{
    std::string PlotCommand = "x=[0 1 2 3 4 5];y=[0 1 4 9 16 25];plot(x, y);";
    void * vpDcom = NULL;
    int iReturnValue;
    engOpenSingleUse(PlotCommand.c_str(), vpDcom, &iReturnValue);
}

The code compiles and runs successfully without any compiler errors or run time error messages. The “Matlab Command Window” opens; I get a screen like below:

Empty Matlab Command Window

As you see, the command window is empty. There is no plotting window on the screen.
When I manually type the command into this window, I get the plotting without any error, like below:

Manually typed command to the command window

This is the official documentation page for the engOpenSingleUse() function:
http://www.mathworks.com/help/techdoc/apiref/engopensingleuse.html

I added <MatlabInstallationDir>\extern\lib\win64\microsoft\libeng.lib library in my project (I’m compiling in x64 debug configuration).
I included <MatlabInstallationDir>\extern\include\engine.h header file.
I typed !matlab /regserver command to the main Matlab window (as described in the documentation page of the engOpenSingleUse() function) to make sure Matlab engine is registered to my OS.

Why doesn’t anything happen when I call the engOpenSingleUse() function?
Why doesn’t a plotting window pop up when I send the string command in the PlotCommand object to plot the plotting?
What am I doing wrong?

OS: Windows 7 Ultimate x64 SP1, up-to-date
IDE: Visual Studio 2010, (Version 10.0.40219.1 SP1Rel)
Matlab: 7.8.0 (R2009a)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:01:08+00:00Added an answer on May 31, 2026 at 4:01 am

    As per the documentation that you linked to, the string argument to engOpenSingleUse is the “start” command – this is NOT a MATLAB command to be executed. engOpenSingleUse just starts the MATLAB engine- you have to call a different function to actually use the engine via engEvalString

    Engine* matlabEngine = engOpenSingleUse(0, vpDcom, &iReturnValue);
    engEvalString(matlabEngine, PlotCommand.c_str());
    

    engOpenSingleUse just means the engine it starts can only be used by one application, not that it is going to execute a single command string.

    From the docs:

    C Syntax

    #include "engine.h"
    Engine *engOpenSingleUse(const char *startcmd, void *dcom,   int *retstatus);
    

    Arguments:

    startcmd String to start
    MATLAB process. On Microsoft Windows systems, the startcmd string must
    be NULL.

    dcom Reserved for future use; must be NULL.

    retstatus Return status; possible cause of failure.

    Returns Microsoft Windows Operating Systems Only Pointer to an engine
    handle, or NULL if the open fails.

    UNIX Operating Systems Not supported on UNIX systems.

    For completeness, I’ll mention that you should also check to make sure the engOpen call returned a non-NULL pointer before continuing with your program.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.