f



Errors when integrating MatLab code into C# program

Hello,

I'm trying to learn how to integrate MatLab code into C#. I'm using Matlab R2010a and Visual Studio 2010. I downloaded the following tutorial and executed the MatLab side of the code:

http://www.mathworks.se/matlabcentral/fileexchange/12987

However, when I tried to compile the C# code in visual studio, I got the following error: 
Could not load file or assembly 'MWArray, Version=2.9.1.0, Culture=neutral, PublicKeyToken=e1d84a0da19db86f' or one of its dependencies. The system cannot find the file specified. 

A quick google search led me to this page, which instructed me to change the target processor to x86:

http://www.mathworks.com/support/solutions/en/data/1-B0JOFC/index.html?solution=1-B0JOFC

However, as soon as I did so, I received a new error: 

System.BadImageFormatException was unhandled

Message="Could not load file or assembly 'MWArray, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=e1d84a0da19db86f' or one of its
dependencies. An attempt was made to load a program with an incorrect
format."

Another google search led me to this page, which said that components generated by MatLab builder x86 are not supported on x64 machines:

http://www.mathworks.com/support/solutions/en/data/1-7457HL/index.html?product=MN&solution=1-7457HL

My MatLab version is 64 bit, but I am still encountering this problem. Is there a workaround?
0
Dan
8/2/2010 7:28:06 PM
comp.soft-sys.matlab 211266 articles. 24 followers. lunamoonmoon (257) is leader. Post Follow

1 Replies
2046 Views

Similar Articles

[PageSpeed] 58

HI,
I am trying something similar to what you did, but with matlab 2012b. And a=
lmost every thing works for me i.e. I can initialize MWStructArray, and wor=
k with it, but in one of the functions where I initialize MWArray, I get th=
e same error as yours. I am completely on 64 bit environment, and building =
my c# in mixed platform mode.
wondering I you found the way around and what was the resolution for your p=
roblem

Thanks,

Jeet
On Monday, 2 August 2010 20:28:06 UTC+1, Dan Piraner  wrote:
> Hello,
>=20
> I'm trying to learn how to integrate MatLab code into C#. I'm using Matla=
b R2010a and Visual Studio 2010. I downloaded the following tutorial and ex=
ecuted the MatLab side of the code:
>=20
> http://www.mathworks.se/matlabcentral/fileexchange/12987
>=20
> However, when I tried to compile the C# code in visual studio, I got the =
following error:=20
> Could not load file or assembly 'MWArray, Version=3D2.9.1.0, Culture=3Dne=
utral, PublicKeyToken=3De1d84a0da19db86f' or one of its dependencies. The s=
ystem cannot find the file specified.=20
>=20
> A quick google search led me to this page, which instructed me to change =
the target processor to x86:
>=20
> http://www.mathworks.com/support/solutions/en/data/1-B0JOFC/index.html?so=
lution=3D1-B0JOFC
>=20
> However, as soon as I did so, I received a new error:=20
>=20
> System.BadImageFormatException was unhandled
>=20
> Message=3D"Could not load file or assembly 'MWArray, Version=3D2.0.0.0,
> Culture=3Dneutral, PublicKeyToken=3De1d84a0da19db86f' or one of its
> dependencies. An attempt was made to load a program with an incorrect
> format."
>=20
> Another google search led me to this page, which said that components gen=
erated by MatLab builder x86 are not supported on x64 machines:
>=20
> http://www.mathworks.com/support/solutions/en/data/1-7457HL/index.html?pr=
oduct=3DMN&solution=3D1-7457HL
>=20
> My MatLab version is 64 bit, but I am still encountering this problem. Is=
 there a workaround?

0
5/17/2013 1:01:13 PM
Reply:

Similar Artilces:

M code into programming C code or MATLAB programming code
hallo firends, Can any body help me write this below code into MATLAB object oriented or C code form please? M=50; % total number of periods. (choose for 1s duration) f0 = 50; % fundamental AC frequency T0 = 1/f0; %fundamental AC period T = M*T0; %Time for M periods (integer M) N=30; % sample points per period. dt = T0/N; % Sample at N points per period (integer N > 20) t = dt*[1:M*N-1]; % Sampling time array A0=120/2; % amplitude of AC signal. Divide by 2 or maybe sqrt (2) ? AC=A0*sin(f0*t*2*pi); % create AC signal. DC0=50; % DC amplitude DC=DC0*ones(1,length...

C/C++ in matlab and matlab in C/C++ ?
Is it possible to read C/C++ code in matlab and the other way around too? Hi, as long as C or C++ are written in text files you can edit them in the matlab editor. To see the special character of C or C++ coding language, in the editor go to menus: file>preferences>Edito/Debugger>language and on popup "Language" select "C/C++". This does not allow you to run the C/C++ code, just to view it i nicer way... regards, chris saneman <asdfsdf@asd.com> wrote in message <frl846 $f8i$2@news.net.uni-c.dk>... > Is it possible to read C/C...

MATLAB algorithm to MATLAB function code or C code
hallo firends, Can any body help me write this below code into MATLAB object oriented code or C code form please? M=50; % total number of periods. (choose for 1s duration) f0 = 50; % fundamental AC frequency T0 = 1/f0; %fundamental AC period T = M*T0; %Time for M periods (integer M) N=30; % sample points per period. dt = T0/N; % Sample at N points per period (integer N > 20) t = dt*[1:M*N-1]; % Sampling time array A0=120/2; % amplitude of AC signal. Divide by 2 or maybe sqrt (2) ? AC=A0*sin(f0*t*2*pi); % create AC signal. DC0=50; % DC amplitude DC=DC0*ones(1,length(t)); % create a DC signal that is constant of length t S=AC+DC; % total signal is AC signal + DC signal figure(1); plot(t,S); % plot signal. xlabel('time');ylabel('Signal'); title('Total Signal'); % filter components fAC=S-mean(S); % here is the AC component fDC=mean(S); % here is the DC component figure(2); plot(t,fAC,'r',t,fDC,'b'); % plot AC and DC signals legend('AC','DC'); xlabel('time');ylabel('Signal'); title('Signal with only AC component'); figure(3); plot(t,fDC,'b'); % plot DC signal legend('DC'); xlabel('time');ylabel('Signal'); title('Signal with only DC component'); figure(4); % best to plot in Fourier domain u=abs(fftshift(fft(S))); NumPoints=length(t); freq=(1/dt)*[1:NumPoints]/NumPoints; % create frequency axis freq=fre...

converting c++ code to Matlab code using Matlab 9
im working on a project using matlab. i want to use some of the already writen codes in C++. i want to use these codes in my project rather than writing them from scratch. is there some way or a chunk of code that might convert C++ code to matlab code or a ".c" file to ".m" file. please if anyone knows do let me know at the earliest.thanks "fatima " <fatima_naseem2002@yahoo.com> wrote in message <i8ugqn$e9p$1@fred.mathworks.com>... > im working on a project using matlab. i want to use some of the already writen codes in C++. i want to use these c...

methods to call matlab in C C++ and call C C++ in matlab
Hi, I am reading the help documents about how to program matlab and C C++ together and my questions are a little bit general. It seems that are several ways to call matlab in C C++ and another several ways to call C C++ in matlab. Please correct me if I am wrong or missing something when I try to list them. To call matlab code in C C++, are there two methods available? The first one is Matlab engine and the second one is to use MATLAB Compiler mcc to create C or C++ shared libraries from your MATLAB code. To call C C++ in matlab, are there also two methods? The first one is to call funct...

Integrating C#/Matlab !! ?? Errors !
I used the Matlab help to integrate Matlab functions in C#. I was successful in making an assembly for the m-file given below ! read_aud.m: ---------------------------------------------------------------------------------------------------------------- % Reading the wav-file .... % 'a' is a string that represents the path of the *.wav file function read_aud(a) [y f] = wavread(a); t = 0:1/f:(length(y)-1)/f; plot(t, y), grid on; n = length(y)-1; t1 = 0:f/n:f; fou = abs(fft(y)); figure, plot(t1,fou), grid on; -----------------------------------------------------------------------------...

Shall i use the misrosoft Visual c++ code from a m-file generated from matlab in Visual C++ with out matlab runtime environment
undefined ...

MatLab Error Of This program has been modified outside MatLab editor
Hi, I am running a MatLab program I've run many times before, and now when I try to run it, I get a message saying : "This program has been modified outside of the MatLab editor. Do you want to reload it?" I've moved the program to a new directory, but I've run MatLab progs from that directory before, so I am perplexed. Can anyone tell me what to do? TIA, Matt In article <972bbd06-3687-4253-9aa0-a08acf91d117@z38g2000hsc.googlegroups.com>, junoexpress <MTBrenneman@gmail.com> wrote: >I am running a MatLab program I've run many times before, and now when >I try to run it, I get a message saying : >"This program has been modified outside of the MatLab editor. Do you >want to reload it?" >I've moved the program to a new directory, but I've run MatLab progs >from that directory before, so I am perplexed. >Can anyone tell me what to do? Use Save As to save the current version under a different name. Then allow Matlab to reload the file. Save that, and then compare the two saved versions to determine what the differences are, and create an appropriately merged version. -- "There is nothing so bad but it can masquerade as moral." -- Walter Lippmann junoexpress <MTBrenneman@gmail.com> wrote in message <972bbd06-3687-4253-9aa0- a08acf91d117@z38g2000hsc.googlegroups.com>... > Hi, >...

Converting Matlab code to C using Matlab Compiler
Hello All, Please can I get some guidance on how to Convert a structure from Matlab code to C code using Matlab Compiler. Kind regards Sammy ...

Call C code from Matlab -> Matlab crash
Hello, I have a problem calling C code from Matlab. The mex file compilation is ok. When I run the program Matlab (7.3) crashes. Below is the mexFunction code. Any idea is welcome. (I think the main part of the code (middle part) is not useful for the crash problem, but I put it anyway). //########################################################### #include "math.h" #include "mex.h" void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // Standard variables int p,r,h,i,j,f,w; // Indices for loop int MAX_NBM = 1000; int MAX_DIM = 10; int MAX_NB_CLUST = 20; double *SF, *km, *new_data; int size, dim, K, nbm, aux_size, count_bis, count_aux; double diam_max, diam, vec1_p, vec2_p, dist_min, dis; int combi[1000000][2]; int dist_aux[1000000][2]; /* Check for proper number of arguments. */ if (nrhs != 5) { mexErrMsgTxt("5 input required."); } else if (nlhs > 1) { mexErrMsgTxt("Too many output arguments"); } // Input parameter (MATLAB) new_data = mxGetPr(prhs[0]); size = (int)mxGetScalar(prhs[1]); dim = (int)mxGetScalar(prhs[2]); K = (int)mxGetScalar(prhs[3]); km = mxGetPr(prhs[4]); // Output parameter (MATLAB) plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); SF = mxGetPr(plhs[0]); // Other variables nbm = size/dim; // Number of points printf("Taille: %d\n",nbm); printf("Dimension: %d\n",dim); //#############################...

Need Help on Matlab C code S function error with VS 2005 C++ compiler
I am using a MS Vista Utimate OS on a 64 bit PC with MATLAB R2007b. I have MS Visual Studio 2005 Pro installed in the same PC. When I compile a C code S function, I got the following error with Microsoft Visual C++ compiler (see mex -setup output list below). By the way, the same code compiled with icc.exe on a 32 bit PC with WinXP OS and worked fine. Please help me with some insight into this compilation problem. mex('s_xmp6L2.c') s_xmp6L2.c s_xmp6L2.c(39) : warning C4013: 'mdlCheckParameters' undefined; assuming extern returning int s_xmp6L2.c(55) : error C2371: '...

Integrate Matlab module in C++ program
Hi, I need your help for programming a C++ program which windows. And, I want to send to matlab data to compute and Matlab returns a graph to put it into my C++ program interface. For instance, a window with a picture area and a textbox and a button. I fill the textbox and click the button. Matlab computes data and sends back a graph to put into the picture area. How can I do it ? Thanks very much PS : I use Matlab 7.0.1. ...

vectorized computation in C++ such as those in Matlab (Matlab to C++)?
Dear all, Can C++/STL/Boost do the vectorized calculation as those in Matlab? For example, in the following code, what I really want to do is to send in a vector of u's. All other parameters such as t, l1, l2, l3, etc. are scalars... But u is a vector. Thus, t6 becomes a vector. t9 is an element-wise multiplication... The following code was actually converted from Matlab. If vectorized computation is not facilitated, then I have to call this function millions of times. But if vectorized computation is okay, then I can send in just a u vector with batch elements a time. I have many such code in Matlab need to be converted into C++ with vectorization. Any thoughts? Thank you! double t5, t6, t7, t9, t11, t13, t16, t20, t23, t27, t32, t34, t36, t37, t38, t42, t44, t47, t48, t51, t52, t54, t59, t60, t61, t66, t67, t69, t74, t75, t76, t81, t82, t84, t87, t105, t106, t110, t112; t5 = exp(-t * l1 - t * l2 - t * l3); t6 = t * u; t7 = mu1 * mu1; t9 = u * u; t11 = kappa * kappa; t13 = 0.1e1 / (t9 * t7 + t11); > Dear all, > > Can C++/STL/Boost do the vectorized calculation as those in Matlab? > > For example, in the following code, what I really want to do is to > send in a vector of u's. > > All other parameters such as t, l1, l2, l3, etc. are scalars... > > But u is a vector. > > Thus, t6 becomes a vector. > > t9 is an element-wise multiplication... > > The following code was actually converted f...

how to convert matlab program to c code
DEAR...i have written a matlab program to find the edge of an image..i want to convert it into c code....so please help me how to convert it into c.The program is shown below SHINE function ret=main(filename); % filename=input('enter the input file name','s') in=imread(filename); out=edge(in(:,:,1),'canny'); figure;imshow(out); imwrite(out,'out.bmp','BMP'); shine t wrote: > DEAR...i have written a matlab program to find the edge of an image..i want to convert > it into c code....so please help me how to convert it into c. Please review the fo...

matlab beginner: calling matlab from C/C++
I'm relatively new to the world of Matlab. I want to call my matlab own code from a C/C++ program on a machine with matlab installed. Do I need to compile the matlab code using matlab compiler tool or the matlab engine is enough for this? Thanks a lot for your help On Nov 28, 10:03 am, "Paeo Campigotto" <campigo...@dit.unitn.it> wrote: > I'm relatively new to the world of Matlab. > I want to call my matlab own code from a C/C++ program on a > machine with matlab installed. > Do I need to compile the matlab code using matlab compiler > tool or the matla...

Call C code from Matlab -> Matlab crash #2
Hello, I have a problem calling C code from Matlab. The mex file compilation is ok. When I run the program Matlab (7.3) crashes. Below is the mexFunction code. Any idea is welcome. (I think the main part of the code (middle part) is not useful for the crash problem, but I put it anyway). //########################################################### #include "math.h" #include "mex.h" void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // Standard variables int p,r,h,i,j,f,w; // Indices for loop int MAX_NBM = 1000; int MAX_DIM = 10; in...

Can't i install Matlab in c:\program files\matlab?
Hello, I tried to install matlab in c:\program files\matlab but when i choose the folder it says it doesn't allow spaces in it. Should Matlab be installed only in the root? How can i install Matlab in c:\program files\matlab? Thanks, shapper > I tried to install matlab in c:\program files\matlab but when i > choose the folder it says it doesn't allow spaces in it. That is true > Should Matlab be installed only in the root? You can install it in any directory that doesn't contain a space in the path. > How can i install Matlab in c:\program files\matlab? You ca...

Error when converting matlab code .m to C++
Hello I use the command: mcc -m -v M2C.m Trying to convert matlab code .m to C++, I get the following error : Compiler version: 4.9 (R2008b) Warning: Name is nonexistent or not a directory: C:\Program Files\MATLAB\R2008b\toolbox\compiler\patch. Warning: Name is nonexistent or not a directory: C:\Program Files\MATLAB\R2008b\toolbox\compiler\patch. Processing C:\Program Files\MATLAB\R2008b\toolbox\matlab\mcc.enc Processing include files... 2 item(s) added. Processing directories installed with MCR... The file mccExcludedFiles.log contains a list of functions excluded...

matlab beginner: calling matlab from C/C++ #2
I'm relatively new to the world of Matlab. I want to call my matlab own code from a C/C++ program on a machine with matlab installed. Do I need to compile the matlab code using matlab compiler tool or the matlab engine is enough for this? Thanks a lot for your help ...

Conversion from MATLAB to C/C++ using MATLAB compiler
I am working on conversion of .m files to c/c++. I am using the MATLAB compiler version 3.0 and MATLAB version 6.5.1. There seem to be a few functions which do not seem to get converted. The error i got while using functions like TRAIN, NETWORK and INIT (all neural-networks related functions used in the general neural network programs, newpnn.m etc) is The MATLAB compiler does not currently support MATLAB object oriented programming and the functions TRAIN , NETWORK and INIT would produce a run-time error. Could anyone please tell me as to how i can circumnavigate this problem or solve this...

calling matlab code from Visual Studio & converting standard c types to matlab
Hiya, I'm writing c language code & I'd like to be able to integrate a number of matlab functions to my code. I've tried to do this with the visual studio add in, but it always generates errors. I'm able to compile c code with the matlab compiler, but whenever I try to call a matlab function this causes errors. How does one compile c++ code with matlab? And when I'm at it, how can standard c variable types(int, double...) be converted to matlab types (and in the opposite direstion too)? Thanks for your help ...

Logical error converting Matlab matrix code to C
I apologize if this isn’t really a question that should be posted on the Mathworks forum, but I have some Matlab m-code that involves a lot of matrix operations, which I had to convert to C code. I’m hoping that there is someone on this forum who has both Matlab and C expertise. I’ve reviewed my code’s logic numerous times, and can’t yet find the logical flaw that’s preventing my C code from matching my m-file’s values. Here’s a description of the code, and of the bug: ~ the Matlab code multiplies the output of the calls to trans_axis() (output = 4x4 matrix of doubles), by the goalTM o...

how to convert Matlab code to C code
Hi everyone, Can any one tell me how to convert matlab to c?? Regards. On 5/8/2012 4:36 PM, WMS wrote: > Hi everyone, > Can any one tell me how to convert matlab to c?? > > Regards. http://www.mathworks.com/products/matlab-coder/ "MATLAB Coder™ generates standalone C and C++ code from MATLAB code" ...

convert C code to matlab code
for (ix=0; ix< iNx; ix++) for (iy=0; iy< iNy; iy++) { fMeanIn += pfIm0[X(ix,iy)]*pfu[X(ix,iy)]; fNormalizationIn += pfu[X(ix,iy)]; fMeanOut += pfIm0[X(ix,iy)]*(1.0-pfu[X(ix,iy)]); fNormalizationOut += 1.0-pfu[X(ix,iy)]; } the above code is C code.... how to convert this into matlab code.... i'm getting error in pfIm0[X(ix,iy)].... please help me to solve it out... ...

Web resources about - Errors when integrating MatLab code into C# program - comp.soft-sys.matlab

Integrating Github and Redmine
I've been a fan and user of Atlassian's excellent Jira since the company was founded back in 2002, but I needed the ability to set up some quick-hit ...

Integrating sphere - Wikipedia, the free encyclopedia
An Integrating sphere (also known as an Ulbricht sphere) is an optical component consisting of a hollow spherical cavity with its interior covered ...

Omega, BMW Take Gold, Silver For Integrating Facebook Into London 2012 Olympics Sponsorships
... Olympic Games in London set to start July 27 and run through Aug. 12, watch maker Omega and automaker BMW are doing the best jobs at integrating ...

Under the Hood: Integrating standalone mobile app features into Facebook for iOS - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Under the Hood: Integrating standalone mobile app features into Facebook for iOS geschrieben. ...

Overview: Integrating Facebook Connect With Your Website
Last week at Facebook’s f8 developer conference, CEO Mark Zuckerberg formally announced Facebook Connect , Facebook’s new program that extends ...

Integrating MFDs with Cloud Fax Services Webinar - eFax Corporate® - YouTube
http://enterprise.efax.com - Corporate users may think that they don’t need fax within their organization because they simply scan a paper document ...

Children integrating technology into study and play as computer use rises
Children integrating technology into study and play as computer use rises

Cisco Systems, Inc. : New Cisco Unified Access Solution Accelerates BYOD Business Innovation by Integrating ...
Cisco Unified Access Makes IT More Responsive to the Business, Simplifying IT Operations by Uniting Wired and Wireless Networks, Policy and Management ...

Uber introduces API for integrating the transportation service into other apps
... app on iPhone and Android, and check out the Uber care package the company sends new employees. Today Uber is taking a major step toward integrating ...

The Aspiring Lateral: Integrating Yourself
Because the lateral journey does not end when you place the potted plant and picture of your family on your new desk. Continue reading » Follow ...

Resources last updated: 3/23/2016 8:12:02 AM