mixed-programming

Calling a global string variable from Fortran in C causes segmentation fault

…衆ロ難τιáo~ 提交于 2019-12-24 06:38:22
问题 I'm trying to call a global string variable which is defined in a Fortran subroutine, in C. the C code is Cfile.c : #include <stdio.h> typedef struct { int length; char* string; } fstring; extern fstring stringf_; void fortfunc_(); int main() { fstring stringC = stringf_; stringC.string[stringC.length-1] = '\0'; printf("%s \n",stringC.string); return 0; } and FORTRAN code is Ffile.f : subroutine fortfunc() character*30 string common/stringF/ string string = 'this is a string in FROTRAN77'

Call MATLAB directly (multiple threading) in Visual Studio

你离开我真会死。 提交于 2019-12-22 01:17:56
问题 Currently I am trying to call MATLAB directly in Visual Studio, but it seems not working. To be clear, take the following demo case as an example, i.e. use MATLAB to compute 2+3 . It is expected that the result, i.e. ans = 5 , should be printed in line printf("%s\n", buf); , which turns out to be empty. By the way, the MATLAB engine is opened ( engOpen() ) successfully. #include <stdio.h> #include <thread> #include "engine.h" Engine *matlab; void thread_func() { // set printing buffer char

Are there C like pre-processor directives for Octave and Scilab to be used for intercompatible code?

我的梦境 提交于 2019-12-20 04:07:55
问题 In C / C++ languages one can use macros or as called "per-processor directives" to instruct the compiler how the code should be read. The simple commands of #def , #ifdef , #ifndef , #else , #endif ... give the compiler the ability to check for Operating system, compiler and other environment information. I know Octave and Scilab are interpreted languages, but I'm wondering if is there any way to tell the interpreter to replaces parts of script while loading it? For example can I write a code

How to call Matlab functions from Visual studio mfc project?

时光怂恿深爱的人放手 提交于 2019-12-12 01:38:47
问题 What I have done is following the guidline in this website Now, I want to use some functions like rgb2gray() and imresize() ... but I dont know how to use them, or I dont know which header file should I include in my project? I have tried other way by creating a C++ shared-library in Matlab, then used it in VS 2012, but I could not add the DLL file to my project when I added new references. it is like that: Please help me! thanks in advance. 回答1: If you really want to call Matlab inside

How to execute a Matlab function in MS Visual C++? [duplicate]

一笑奈何 提交于 2019-12-11 09:05:44
问题 This question already has answers here : How to execute a Matlab script from C++ (3 answers) Closed 7 months ago . I have 2 separate functions which one is in MS visual C++ and another is in Matlab. How do I execute the Matlab file in MS VISUAL? Is there a windows function to load the .m file and execute it straightly? 回答1: Two ways to run Matlab code in C++: Call MATLAB Engine directly. The target machine needs to have the MATLAB installed. Check out Call MATLAB Functions from C and C++

Call MATLAB directly (multiple threading) in Visual Studio

三世轮回 提交于 2019-12-04 18:38:50
Currently I am trying to call MATLAB directly in Visual Studio, but it seems not working. To be clear, take the following demo case as an example, i.e. use MATLAB to compute 2+3 . It is expected that the result, i.e. ans = 5 , should be printed in line printf("%s\n", buf); , which turns out to be empty. By the way, the MATLAB engine is opened ( engOpen() ) successfully. #include <stdio.h> #include <thread> #include "engine.h" Engine *matlab; void thread_func() { // set printing buffer char buf[1001]; engOutputBuffer(matlab, buf, 1000); // call MATLAB engEvalString(matlab, "2+3"); printf("%s\n"

Are there C like pre-processor directives for Octave and Scilab to be used for intercompatible code?

谁都会走 提交于 2019-12-02 04:47:54
In C / C++ languages one can use macros or as called "per-processor directives" to instruct the compiler how the code should be read. The simple commands of #def , #ifdef , #ifndef , #else , #endif ... give the compiler the ability to check for Operating system, compiler and other environment information. I know Octave and Scilab are interpreted languages, but I'm wondering if is there any way to tell the interpreter to replaces parts of script while loading it? For example can I write a code which is commented based on Scilab syntax // and then instruct the interpreter to read them as Octave