Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Is it possible to execute the MatLab "Disp" function from DLL?

Asked by Vincent on 30 Nov 2012

A library file & .dll has been created using MatLab so that I could use it in my 64-bit C application. The MatLab script that I would like to call from the C application creates a diary, and uses the "disp" function to generate the text file.

When I execute the MatLab script from my C application, the following errors are generated: "Error writing to output stream" and "Error using ==> disp". If I change my MatLab script so that the text file is generated using fprintf, I do not see the error.

Is there a way that I can resolve the issue without using the "fprintf" approach?

2 Comments

Walter Roberson on 30 Nov 2012

Are you using MATLAB Compiler, or MATLAB Coder?

Vincent on 3 Dec 2012

The .lib, .h, and .dll files were generated with the Matlab Compiler. I added these files to my ANSI C application built in LabWindows. I have the Compiler Runtime installed on the PC where the C application will execute.

Vincent

Products

No products are associated with this question.

1 Answer

Answer by Image Analyst on 30 Nov 2012

You can just put the name of the variable all by itself on the line of code and I would think that it would display it just like it does when you do the same thing in the command window. By the way, what's wrong with fprintf()? And it's not clear to me whether you want to print to the console window (like disp should do), or to a text file (like you mentioned). Where do you want to print your stuff, the console window, a text file, or both?

1 Comment

Vincent on 3 Dec 2012

I want to print to a text file only. There is nothing wrong with fprintf, but we wanted to see if there's a way to get the diary/disp method to work when executed inside of a C application using .lib/.dll. This is what we have used now to print to file, and we wanted to make the least amount of changes to the Matlab script as possible.

Image Analyst

Contact us