 |
|
 |
Asalamulaikum I need a project that is based on neural networks using any program ( matlab, c++, prolog, n etc).
If you could be of any help i will be very grateful. please.
I'm on a dead line with my projects date. I know I've said on such a short notice but a project on neural networks is hard to find which has not been uploaded on the internet. Kindly help me in this regard please. Thankyou! I will be waiting for you response. email : sameenhkhan@hotmail.com Sameen
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi I having some problems with the mex stuff. Im working on a c++ project, which uses the boost libraries, so im including files like the following: #include <boost/numeric/ublas/vector.hpp> But when I try to compile it from matlab, it doesnt work I tried: mex mexi.cpp -L/boostlib/boost/numeric/ublas -lvector.hpp and a dozen other similar stuff. Id really be thankful, if smbody could help me, I gotta find this out for my project work and have no clue. Thanks so much Nisha K
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
Can U please tell me the link from which I can download "MCC - MATLAB to C/C++ compiler" ?
Regards, Arun Kumar.A
|
| Sign In·View Thread·PermaLink | 3.43/5 (3 votes) |
|
|
|
 |
|
|
 |
|
 |
Hi. I want to create mex file (.mexw32) from .m file in Matlab 7.1. It seems that it is no longer supported. I used to call mcc -x in Matlab 6.5.1 to generate .dll files that i can run in Matlab. How do I do that in 7.1? Thanks for the help.
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
hi I appreciate your effort very much. when I compile a mex file in matlab, it could not find all the headers files (.h) needes ... I always have a massege of type " Can not includ ....h file) , althought the h file is placed in the include directory in matlab root .. and in the current directory would you please help me? best regards
Majd
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi everybody!
I try to compile the following myfile.c file with the mex functionality of Matlab but it does not work.I get the message:
Mex file entry point is missing. Please check the (case-sensitive) spelling of mexFunction (for C MEX-files), or the (case-insensitive) spelling of MEXFUNCTION (for FORTRAN MEX-files). ??? Invalid MEX-file 'C:\MATLAB71\extern\myfile.mexw32': The specified module could not be found.
How should I write a mexfunction in the .C code? The file myfile.c (performs a statistical test) is the following:
---- myfile.c -------------------------------------- #include #include #include #define max(a,b) a>b?a:b
double T2,*h;
//returns T2 statistics void redun(double *x, double *y, int N, int m, int mmax, double epsilon) {
int i, j, s; int IYij, IXYij, IYZij, IXYZij; double disx, disy, disz, *Cy, *Cxy, *Cyz, *Cxyz, mu;
mu=pow(2.0*epsilon,m+2*mmax+1);
Cy = (double *) malloc(N*sizeof(double)); Cxy = (double *) malloc(N*sizeof(double)); Cyz = (double *) malloc(N*sizeof(double)); Cxyz = (double *) malloc(N*sizeof(double));
for (i=0;i!=N;i++) h[i] = Cy[i] = Cxy[i] = Cyz[i] = Cxyz[i] = 0.0;
T2=0.0;
for (i=mmax;i!=N;i++) { Cy[i]=Cxy[i]=Cyz[i]=Cxyz[i]=0.0; for (j=mmax;j!=N;j++) if (j!=i)
{ disx = disy = 0.0; for (s=1;s!=m+1;s++) disx = max(fabs(x[i-s]-x[j-s]),disx);
for (s=1;s!=mmax+1;s++) disy = max(fabs(y[i-s]-y[j-s]),disy);
if (disy <= epsilon) { Cy[i]++;
if (disx <= epsilon) { Cxy[i]++; }
disz = max(fabs(y[i]-y[j]),disy); if (disz <= epsilon) { Cyz[i]++; if (disx <= epsilon) { Cxyz[i]++; } } } // end condition |Yi - Yj| < epsilon } // end loop over j
Cy[i] /= (double)(N-mmax); Cxy[i] /= (double)(N-mmax); Cyz[i] /= (double)(N-mmax); Cxyz[i] /= (double)(N-mmax);
h[i] += 2.0/(double) mu*(Cxyz[i]*Cy[i] - Cxy[i]*Cyz[i])/6.0;
}
for (i=mmax;i!=N;i++) { for (j=mmax;j!=N;j++) if (j!=i) {
IYij = IXYij = IYZij = IXYZij = 0; disx = disy = 0.0;
for (s=1;s!=m+1;s++) disx = max(fabs(x[i-s]-x[j-s]),disx);
for (s=1;s!=mmax+1;s++) disy = max(fabs(y[i-s]-y[j-s]),disy);
if (disy <= epsilon) {
IYij=1; if (disx <= epsilon) IXYij = 1;
disz = max(fabs(y[i]-y[j]),disy); if (disz <= epsilon) { IYZij = 1; if (disx <= epsilon) IXYZij = 1; } } // end condition |Yi - Yj| < epsilon
h[i] += 2.0/(double) mu*(Cxyz[j]*IYij + IXYZij*Cy[j] - Cxy[j]*IYZij - IXYij*Cyz[j])/(double)(6*(N-mmax)); } // end second loop over j } // end loop over i
for (i=mmax;i!=N;i++) T2 += h[i];
T2 /= (double)(N-mmax); for (i=mmax;i!=N;i++) h[i] -= T2;
free (Cy); free (Cxy); free (Cxyz); free (Cyz);
}
void InsertionSort(double *X, int *S, int M) { int i, *I; int j; int r; double R;
I= (int*) malloc (M*sizeof(int));
for (i=0;i I[i]=i;
for (i=1; i { R = X[i]; r = i; for (j=i-1; (j>=0) && (X[j]>R); j--) { X[j+1] = X[j]; I[j+1] = I[j]; } X[j+1] = R; I[j+1] = r; } for (i=0; i S[I[i]]=i;
}
void uniform (double *X, int M) { int *I, i;
I = (int*) malloc (M*sizeof(int)); InsertionSort(X, I, M);
for (i=0;i X[i] = (double) I[i]/M*3.464101615; // to make unit variance
}
/* normalize the time series to unit std. dev. */
void normalise(double *x, int N) { int i; double mean=0.0, var=0.0;
for (i=0;i!=N;i++) { mean += x[i]; var += x[i]*x[i]; }
mean /= (double)(N); var /= (double)(N); var -= mean*mean;
for (i=0;i!=N;i++) x[i] = (x[i]-mean)/sqrt(var);
return; }
int main(int num_par, char *par[]) { char infil1name[128]="test1.txt",infil2name[128]="test2.txt", outfilname[128]; double *x, *y, tmp, epsilon=.50, VT2, p_T2, p_T21, *ohm, *cov, T2_TVAL, T2_TVAL1, sigma[4][4]; int i, j, l, k, m=1, K, N; long seed; FILE *infil1, *infil2, *outfil;
// enter parameters from outside if (num_par==1) { printf("Input file containing series 1: "); scanf("%s", infil1name);
} else { i=0; do { infil1name[i]=par[1][i]; i++; } while (par[1][i-1]!='\0'); }
if ( (infil1=fopen(infil1name,"r")) == NULL) { fprintf(stderr,"\nError: unable to open file containing series 1...%s\n",infil1name); exit(1); }
i = 0;
while (fscanf(infil1,"%lf", &tmp) != EOF) { i++; } fclose(infil1);
N=i;
if (num_par<3){ printf("Input file containing series 2: "); scanf("%s", infil2name); } else { i=0; do { infil2name[i]=par[2][i]; i++; } while (par[2][i-1]!='\0'); }
if ( (infil2=fopen(infil2name,"r")) == NULL) { fprintf(stderr,"\nError: unable to open file containing series 2.\n"); exit(1); }
i=0; while (fscanf(infil2,"%lf", &tmp) != EOF) { i++; } fclose(infil2);
if ( i!=N) { fprintf(stderr,"\nError: files contain series of different length.\n"); }
if (num_par<4) { printf("Input embedding dimension: "); scanf("%d", &m); } else m=atoi(par[3]);
if (num_par<5) { printf("Input bandwidth: "); scanf("%lf", &epsilon); printf("\n"); } else epsilon=atof(par[4]);
x = (double *) malloc(N*sizeof(double)); y = (double *) malloc(N*sizeof(double));
h = (double *) malloc(N*sizeof(double));
K = (int)(sqrt(sqrt(N))); ohm = (double *) malloc(K*sizeof(double)); cov = (double *) malloc(K*sizeof(double));
// read the series infil1=fopen(infil1name,"r"); infil2=fopen(infil2name,"r");
for (i=0;i { fscanf(infil1,"%lf",&(x[i])); fscanf(infil2,"%lf",&(y[i])); }
normalise(x,N); normalise(y,N);
// redun(x,y, ..) test statistic for X -> Y redun(x,y,N,m,m,epsilon);
ohm[0] = 1.0;
for (k=1;k ohm[k] = 2.0*(1.0-k/(double)(K));
/* determine autocovariance of h[i] */
for (k=0;k!=K;k++) { cov[k] = 0.0; for (i=m+k;i!=N;i++) cov[k] += h[i]*h[i-k];
cov[k] /= (double)(N-m-k); }
T2_TVAL=VT2=0.0;
/* variance of T2 */
for (k=0;k!=K;k++) VT2 += 9.0*ohm[k]*cov[k];
T2_TVAL = T2*sqrt(N-m)/sqrt(VT2);
if (T2_TVAL>0) p_T2 = 0.5 - .5*erf(T2_TVAL/sqrt(2.0)); else p_T2 = 0.5 + .5*erf(T2_TVAL/sqrt(2.0));
if ((num_par<6) || ((outfil=fopen(par[5],"w")) == NULL)) outfil=stdout; else printf("The results are saved to the file: %s\n",par[5]); fprintf(outfil,"Series length=%d, embedding dimension=%d, bandwidth=%f\n",N,m,epsilon); fprintf(outfil,"\nNull hypothesis: %s does not cause %s\n",infil1name,infil2name); fprintf(outfil,"T statistics=%.3f, p-value=%1.5f\n",T2_TVAL,p_T2);
redun(y,x,N,m,m,epsilon);
ohm[0] = 1.0;
for (k=1;k ohm[k] = 2.0*(1.0-k/(double)(K));
/* determine autocovariance of h[i] */
for (k=0;k!=K;k++) { cov[k] = 0.0; for (i=m+k;i!=N;i++) cov[k] += h[i]*h[i-k];
cov[k] /= (double)(N-m-k); }
T2_TVAL=VT2=0.0;
/* variance of T2 */
for (k=0;k!=K;k++) VT2 += 9.0*ohm[k]*cov[k];
T2_TVAL = T2*sqrt(N-m)/sqrt(VT2);
if (T2_TVAL>0) p_T2 = 0.5 - .5*erf(T2_TVAL/sqrt(2.0)); else p_T2 = 0.5 + .5*erf(T2_TVAL/sqrt(2.0));
fprintf(outfil,"\nNull hypothesis: %s does not cause %s\n",infil2name,infil1name); fprintf(outfil,"T statistics=%.3f, p-value=%1.5f\n",T2_TVAL,p_T2);
fcloseall(); return(0); }
sotiria
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi everybody!
I try to compile the following myfile.c file with the mex functionality of Matlab but it does not work.I get the message:
Mex file entry point is missing. Please check the (case-sensitive) spelling of mexFunction (for C MEX-files), or the (case-insensitive) spelling of MEXFUNCTION (for FORTRAN MEX-files). ??? Invalid MEX-file 'C:\MATLAB71\extern\myfile.mexw32': The specified module could not be found.
How should I write a mexfunction in the .C code? The file myfile.c (performs a statistical test) is the following:
---- myfile.c -------------------------------------- #include #include #include #define max(a,b) a>b?a:b double T2,*h; //returns T2 statistics void redun(double *x, double *y, int N, int m, int mmax, double epsilon) { int i, j, s; int IYij, IXYij, IYZij, IXYZij; double disx, disy, disz, *Cy, *Cxy, *Cyz, *Cxyz, mu; mu=pow(2.0*epsilon,m+2*mmax+1); Cy = (double *) malloc(N*sizeof(double)); Cxy = (double *) malloc(N*sizeof(double)); Cyz = (double *) malloc(N*sizeof(double)); Cxyz = (double *) malloc(N*sizeof(double)); for (i=0;i!=N;i++) h[i] = Cy[i] = Cxy[i] = Cyz[i] = Cxyz[i] = 0.0; T2=0.0; for (i=mmax;i!=N;i++) { Cy[i]=Cxy[i]=Cyz[i]=Cxyz[i]=0.0; for (j=mmax;j!=N;j++) if (j!=i) { disx = disy = 0.0; for (s=1;s!=m+1;s++) disx = max(fabs(x[i-s]-x[j-s]),disx); for (s=1;s!=mmax+1;s++) disy = max(fabs(y[i-s]-y[j-s]),disy); if (disy <= epsilon) { Cy[i]++; if (disx <= epsilon) { Cxy[i]++; } disz = max(fabs(y[i]-y[j]),disy); if (disz <= epsilon) { Cyz[i]++; if (disx <= epsilon) { Cxyz[i]++; } } } // end condition |Yi - Yj| < epsilon } // end loop over j Cy[i] /= (double)(N-mmax); Cxy[i] /= (double)(N-mmax); Cyz[i] /= (double)(N-mmax); Cxyz[i] /= (double)(N-mmax); h[i] += 2.0/(double) mu*(Cxyz[i]*Cy[i] - Cxy[i]*Cyz[i])/6.0; } for (i=mmax;i!=N;i++) { for (j=mmax;j!=N;j++) if (j!=i) { IYij = IXYij = IYZij = IXYZij = 0; disx = disy = 0.0; for (s=1;s!=m+1;s++) disx = max(fabs(x[i-s]-x[j-s]),disx); for (s=1;s!=mmax+1;s++) disy = max(fabs(y[i-s]-y[j-s]),disy); if (disy <= epsilon) { IYij=1; if (disx <= epsilon) IXYij = 1; disz = max(fabs(y[i]-y[j]),disy); if (disz <= epsilon) { IYZij = 1; if (disx <= epsilon) IXYZij = 1; } } // end condition |Yi - Yj| < epsilon h[i] += 2.0/(double) mu*(Cxyz[j]*IYij + IXYZij*Cy[j] - Cxy[j]*IYZij - IXYij*Cyz[j])/(double)(6*(N-mmax)); } // end second loop over j } // end loop over i for (i=mmax;i!=N;i++) T2 += h[i]; T2 /= (double)(N-mmax); for (i=mmax;i!=N;i++) h[i] -= T2; free (Cy); free (Cxy); free (Cxyz); free (Cyz); } void InsertionSort(double *X, int *S, int M) { int i, *I; int j; int r; double R; I= (int*) malloc (M*sizeof(int)); for (i=0;i I[i]=i; for (i=1; i { R = X[i]; r = i; for (j=i-1; (j>=0) && (X[j]>R); j--) { X[j+1] = X[j]; I[j+1] = I[j]; } X[j+1] = R; I[j+1] = r; } for (i=0; i S[I[i]]=i; } void uniform (double *X, int M) { int *I, i; I = (int*) malloc (M*sizeof(int)); InsertionSort(X, I, M); for (i=0;i X[i] = (double) I[i]/M*3.464101615; // to make unit variance } /* normalize the time series to unit std. dev. */ void normalise(double *x, int N) { int i; double mean=0.0, var=0.0; for (i=0;i!=N;i++) { mean += x[i]; var += x[i]*x[i]; } mean /= (double)(N); var /= (double)(N); var -= mean*mean; for (i=0;i!=N;i++) x[i] = (x[i]-mean)/sqrt(var); return; } int main(int num_par, char *par[]) { char infil1name[128]="test1.txt",infil2name[128]="test2.txt", outfilname[128]; double *x, *y, tmp, epsilon=.50, VT2, p_T2, p_T21, *ohm, *cov, T2_TVAL, T2_TVAL1, sigma[4][4]; int i, j, l, k, m=1, K, N; long seed; FILE *infil1, *infil2, *outfil; // enter parameters from outside if (num_par==1) { printf("Input file containing series 1: "); scanf("%s", infil1name); } else { i=0; do { infil1name[i]=par[1][i]; i++; } while (par[1][i-1]!='\0'); } if ( (infil1=fopen(infil1name,"r")) == NULL) { fprintf(stderr,"\nError: unable to open file containing series 1...%s\n",infil1name); exit(1); } i = 0; while (fscanf(infil1,"%lf", &tmp) != EOF) { i++; } fclose(infil1); N=i; if (num_par<3){ printf("Input file containing series 2: "); scanf("%s", infil2name); } else { i=0; do { infil2name[i]=par[2][i]; i++; } while (par[2][i-1]!='\0'); } if ( (infil2=fopen(infil2name,"r")) == NULL) { fprintf(stderr,"\nError: unable to open file containing series 2.\n"); exit(1); } i=0; while (fscanf(infil2,"%lf", &tmp) != EOF) { i++; } fclose(infil2); if ( i!=N) { fprintf(stderr,"\nError: files contain series of different length.\n"); } if (num_par<4) { printf("Input embedding dimension: "); scanf("%d", &m); } else m=atoi(par[3]); if (num_par<5) { printf("Input bandwidth: "); scanf("%lf", &epsilon); printf("\n"); } else epsilon=atof(par[4]); x = (double *) malloc(N*sizeof(double)); y = (double *) malloc(N*sizeof(double)); h = (double *) malloc(N*sizeof(double)); K = (int)(sqrt(sqrt(N))); ohm = (double *) malloc(K*sizeof(double)); cov = (double *) malloc(K*sizeof(double)); // read the series infil1=fopen(infil1name,"r"); infil2=fopen(infil2name,"r"); for (i=0;i { fscanf(infil1,"%lf",&(x[i])); fscanf(infil2,"%lf",&(y[i])); } normalise(x,N); normalise(y,N); // redun(x,y, ..) test statistic for X -> Y redun(x,y,N,m,m,epsilon); ohm[0] = 1.0; for (k=1;k ohm[k] = 2.0*(1.0-k/(double)(K)); /* determine autocovariance of h[i] */ for (k=0;k!=K;k++) { cov[k] = 0.0; for (i=m+k;i!=N;i++) cov[k] += h[i]*h[i-k]; cov[k] /= (double)(N-m-k); } T2_TVAL=VT2=0.0; /* variance of T2 */ for (k=0;k!=K;k++) VT2 += 9.0*ohm[k]*cov[k]; T2_TVAL = T2*sqrt(N-m)/sqrt(VT2); if (T2_TVAL>0) p_T2 = 0.5 - .5*erf(T2_TVAL/sqrt(2.0)); else p_T2 = 0.5 + .5*erf(T2_TVAL/sqrt(2.0)); if ((num_par<6) || ((outfil=fopen(par[5],"w")) == NULL)) outfil=stdout; else printf("The results are saved to the file: %s\n",par[5]); fprintf(outfil,"Series length=%d, embedding dimension=%d, bandwidth=%f\n",N,m,epsilon); fprintf(outfil,"\nNull hypothesis: %s does not cause %s\n",infil1name,infil2name); fprintf(outfil,"T statistics=%.3f, p-value=%1.5f\n",T2_TVAL,p_T2); redun(y,x,N,m,m,epsilon); ohm[0] = 1.0; for (k=1;k ohm[k] = 2.0*(1.0-k/(double)(K)); /* determine autocovariance of h[i] */ for (k=0;k!=K;k++) { cov[k] = 0.0; for (i=m+k;i!=N;i++) cov[k] += h[i]*h[i-k]; cov[k] /= (double)(N-m-k); } T2_TVAL=VT2=0.0; /* variance of T2 */ for (k=0;k!=K;k++) VT2 += 9.0*ohm[k]*cov[k]; T2_TVAL = T2*sqrt(N-m)/sqrt(VT2); if (T2_TVAL>0) p_T2 = 0.5 - .5*erf(T2_TVAL/sqrt(2.0)); else p_T2 = 0.5 + .5*erf(T2_TVAL/sqrt(2.0)); fprintf(outfil,"\nNull hypothesis: %s does not cause %s\n",infil2name,infil1name); fprintf(outfil,"T statistics=%.3f, p-value=%1.5f\n",T2_TVAL,p_T2); fcloseall(); return(0); }
sotiria
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
 |
Hi, i'v a question ... i'm trying to setup c++ compiler(not located) (mex -setup)...
after running a make file that uses mex, compiler couldn't be found ?!?...
message: C:\PROGRAMME\MATLAB71\BIN\MEX.PL: Error: Unable to locate compiler. Use mex -setup to configure your environment properly.
Is there any special option to setup mex correctly in this case?
i'll be very glad to have your answer!
nina
-- modified at 4:38 Tuesday 25th July, 2006
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hi again,
Ye! is exactly what i did! just like mex description!
It gives me:
Try to update options file: C:\Dokumente und Einstellungen\nina.MATRIXWARE\Application Data\MathWorks\MATLAB\R14SP3\mexopts.bat From template: C:\PROGRAMME\MATLAB71\BIN\win32\mexopts\msvc50opts.bat Done . . . *************************************************************************** Warning: The file extension of 32-bit Windows MEX-files was changed from ".dll" to ".mexw32" in MATLAB 7.1 (R14SP3). The generated MEX-file will not be found by MATLAB versions prior to 7.1. Use the -output option with the ".dll" file extension to generate a MEX-file that can be called in previous versions. For more information see: MATLAB 7.1 Release Notes, New File Extension for MEX-Files on Windows ***************************************************************************
i guess it's something with mex.pl (so that i'd said last time!)i've no idea how i could find the problem of this mex.pl!!!
best regards nina
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi again,
it's my problem: it could not find cl.exe file, how should I configure mex -setup ??
make Could not find the compiler "cl" on the DOS path. Use mex -setup to configure your environment properly.
the makefile is: % This make.m is used under Windows
mex -O -c svm.cpp mex -O -c svm_model_matlab.c mex -O svmtrain.c svm.obj svm_model_matlab.obj mex -O svmpredict.c svm.obj svm_model_matlab.obj
could you tell me what is wrong?
thanx, nina
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Mr. Riazi
I'v downloaded "mpgread" & "mpgwrite" packages(which are used to convert MPEG video files to matlab standard movie files & vice versa. But when I debug & run makedll.m file & then call mpgread, for example, in matlab command window ([R, G, B] = mpgread('f:\foreman.mpg', [1:20]) this error message is shown:
------------------------------------------------------------------------ Segmentation violation detected at Mon Jul 05 02:52:27 2004 ------------------------------------------------------------------------
Configuration: MATLAB Version: 7.0.1.24704 (R14) Service Pack 1 MATLAB License: 238685 Operating System: Microsoft Windows XP Window System: Version 5.1 (Build 2600: Service Pack 2) Processor ID: x86 Family 15 Model 2 Stepping 9, GenuineIntel Virtual Machine: Java 1.4.2_04 with Sun Microsystems Inc. Java HotSpot(TM) Client VM (mixed mode) Default Charset: ibm-5348_P100-1997
Register State: EAX = 00000000 EBX = 00000001 ECX = 16131008 EDX = 11081da0 ESI = 0e0fafa4 EDI = 00000006 EBP = 00cddc74 ESP = 00cddc18 EIP = 0e0e774c FLG = 00210246
Stack Trace: [0] mpgread.dll:0x0e0e774c(1, 0x0e0fafa4, 47, 0x11081d80) [1] mpgread.dll:0x0e0e4b32(0x11081d80, 0x00cde6ac, 0x0e0faf90, 0) [2] mpgread.dll:0x0e0e2c6a(0, 0x11081d80, 0x00cde6ac, 0) [3] mpgread.dll:0x0e0e1cce(3, 0x00cde6ac, 2, 0x00cde70c) [4] libmex.dll:_mexRunMexFile(3, 0x00cde6ac, 2, 0x00cde70c) + 103 bytes [5] libmex.dll:public: virtual void __thiscall Mfh_mex::dispatch_file(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(3, 0x00cde6ac, 2, 0x00cde70c) + 157 bytes [6] m_dispatcher.dll:public: virtual void __thiscall Mfh_file::dispatch_fh(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(3, 0x00cde6ac, 2, 0x00cde70c) + 273 bytes [7] m_interpreter.dll:int __cdecl mdDispatch(int,char const *,int,struct mxArray_tag * *,int,struct mxArray_tag * *,class Mfh_MATLAB_fn * *)(487, 0x110ff40c "mpgread", 3, 0x00cde6ac) + 88 bytes [8] m_interpreter.dll:_inDispatchFromStack(487, 0x110ff40c "mpgread", 3, 2) + 801 bytes [9] m_interpreter.dll:enum opcodes __cdecl inDispatchCall(char const *,int,int,int,int *,int *)(0x110ff40c "mpgread", 487, 3, 2) + 138 bytes [10] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag volatile *)(2, 0, 0, 0) + 2359 bytes [11] m_interpreter.dll:int __cdecl inInterPcodeSJ(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag *)(2, 0, 0, 0) + 272 bytes [12] m_interpreter.dll:_inInterPcode(2, 0x78773d54, 0, 0) + 69 bytes [13] m_interpreter.dll:enum inExecutionStatus __cdecl in_local_call_eval_function(int *,struct _pcodeheader *,int *,struct mxArray_tag * * const,enum inDebugCheck)(0x00cdf2c8, 0x00cdf3b4, 2, 1) + 162 bytes [14] m_interpreter.dll:$L73181(0x78773d54, 0x0f954cd0 "[R, G, B] = mpgread('f:\foreman...", 0, 0) + 196 bytes [15] m_interpreter.dll:enum inExecutionStatus __cdecl inEvalCmdWithLocalReturnandtype(char const *,int *,enum inDebugCheck)(0x0f954cd0 "[R, G, B] = mpgread('f:\foreman...", 0, 2, 0x00cdf444 "ôôÍ") + 69 bytes [16] m_interpreter.dll:_inEvalCmdNoEnd(0x0f954cd0 "[R, G, B] = mpgread('f:\foreman...", 0x00cdf4e4, 0x00cdf49c, 0x01493f28) + 16 bytes [17] bridge.dll:_mnParser(0x7c80b529, 0x01493f28, 0, 0) + 431 bytes [18] mcr.dll:public: void __thiscall mcrInstance::mnParser(void)(271268, 0x4d5c3a45, 0x6f6a6861, 0x4d5c6275) + 87 bytes [19] MATLAB.exe:0x00401d2f(4194304, 0, 271268, 0x01493f28) [20] MATLAB.exe:0x00403e45(0x00c5dd60, 0x7c90e1fe "¸±", 0x7ffda000, 0x8054a938) [21] kernel32.dll:0x7c816d4f(0x00403cc0 "jth8U@", 0, 0, 0)
This error was detected while a MEX-file was running. If the MEX-file is not an official MathWorks function, please examine its source code for errors. Please consult the External Interfaces Guide for information on debugging MEX-files.
If it is an official MathWorks function, please follow these steps in reporting this problem to The MathWorks so that we have the best chance of correcting it:
1. Send this crash report to segv@mathworks.com for automated analysis. For your convenience, this information has been recorded in: C:\DOCUME~1\TCTTOH~1\LOCALS~1\Temp\matlab_crash_dump.3800
2. Also, if the problem is reproducible, send the crash report to support@mathworks.com along with: - A specific list of steps that will reproduce the problem - Any M, MEX, MDL or other files required to reproduce the problem - Any error messages displayed to the command window A technical support engineer will contact you with further information.
Thank you for your assistance. Please save your workspace and restart MATLAB before continuing your work.
////////////////////////////////////////////////////////// Please help me to solve the problem.
Thanks in advance & best regards H Mahjoub
-- modified at 20:01 Wednesday 5th July, 2006
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi,
First of all I would like to congratulate you for your articles, that I found to be very good and very informative. The question I have to you is if it is possible to do this exact task using Lcc, instead of Microsoft visual Basic C++ ? The problem is that my company doesn't have VC++, so as we need to call C functions from matlab, I was thinking if it is possible to do this task using other compiler.
My MatLab version is R2006a.
Best regards,
Pedro Cardoso
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
In theory you can use LCC, Watcom, Borland and Microsoft compilers. For other compilers than VC++, you must use proper libraries and preprocessors. Just read MATLAB Compiler documents and also refer to its site.
Best regards, A. Riazi
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
Thank you for your answer. But what's the easier way to call C functions from MatLab ? I tried a simple example that adds two numbers, and it worked correctly, but now I want to make a MEX file that has several functions and call each one of them. The goal is to use a C software from ITU (ITU-R P.452). This software has lots of functions, to read/write from/to a file and do propagation calculations. What can I do to overcome this obstacle ? I searched all over the internet and I can't create a MEX that works with the software.
Best regards, Pedro Cardoso
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Dear Sir, I am very much new to matlab...please tell me the following things... do i need matlab installed on the computer where i want to ship my application developed in vc++ using matlab max file and compiled though mcc and created a lib file.... thanks
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi There is no need to install MATLAB to target machine but you have to install MATLAB redistributable files. Please check Mathworks.com for more info.
Best regards, A. Riazi
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, I created a new S-function from scratch copy of sfun_basic.c file & included my code in. I need to call some functions that are defined in a DLL file. How to include the dll in my code?
Thanks
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi, Basically you must include the DLL header file to your code and also import its library (*.lib).
Best regards, A. Riazi
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks for your reply, but how this can be reached? to import the dll files with the c -file created?
Thanks again
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, I create a mex project a dll C++ project. My project contains many files, but it's under one dll. I will give you an example how I am using my dll. (Suppose I want to call FFT, mexProject('FFT') ; mexProject is name of the dll,FFT is the routine)
I am using a database that a created from a MAT file. I created my database on matlab and with a program I managed to pass it to c++, as a result I have an header and cpp file. Exapmle: The cpp contains ############################################################ #include "type_def.h" #include "phydb_m2h_rf_front_tx.h"
namespace M2HPhyRfFrontTx {
char __MAT2H_RF_FRONT_TX_bw[3]={50, 53, 0};
SPYWORD __MAT2H_RF_FRONT_TX_Coeff[129]={0.000000F, 0.000000F, -0.000000F, -0.000000F, -0.000000F, 0.000000F, 0.000000F , -0.000000F, -0.000000F, -0.000000F, 0.000000F, 0.000001F, 0.000000F, -0.000002F, -0.000003F, 0.000001F, 0.000008F , 0.000007F, -0.000009F, -0.000022F, -0.000004F, 0.000037F, 0.000043F, -0.000025F, -0.000100F, -0.000048F, 0.000125F , 0.000193F, -0.000031F, -0.000339F, -0.000249F, 0.000315F, 0.000657F, 0.000082F, -0.000919F, -0.000900F, 0.000597F , 0.001808F, 0.000639F, -0.002052F, -0.002586F, 0.000764F, 0.004211F, 0.002352F, -0.003866F, -0.006296F, 0.000189F , 0.008609F, 0.006592F, -0.006244F, -0.013714F, -0.002569F, 0.016193F, 0.016273F, -0.008734F, -0.028955F, -0.011380F , 0.031037F, 0.041914F, -0.010655F, -0.075389F, -0.051658F, 0.101508F, 0.298287F, 0.388619F, 0.298287F, 0.101508F , -0.051658F, -0.075389F, -0.010655F, 0.041914F, 0.031037F, -0.011380F, -0.028955F, -0.008734F, 0.016273F, 0.016193F , -0.002569F, -0.013714F, -0.006244F, 0.006592F, 0.008609F, 0.000189F, -0.006296F, -0.003866F, 0.002352F, 0.004211F , 0.000764F, -0.002586F, -0.002052F, 0.000639F, 0.001808F, 0.000597F, -0.000900F, -0.000919F, 0.000082F, 0.000657F , 0.000315F, -0.000249F, -0.000339F, -0.000031F, 0.000193F, 0.000125F, -0.000048F, -0.000100F, -0.000025F, 0.000043F , 0.000037F, -0.000004F, -0.000022F, -0.000009F, 0.000007F, 0.000008F, 0.000001F, -0.000003F, -0.000002F, 0.000000F , 0.000001F, 0.000000F, -0.000000F, -0.000000F, -0.000000F, 0.000000F, 0.000000F, -0.000000F, -0.000000F, -0.000000F , 0.000000F, 0.000000F};
char __MAT2H_RF_FRONT_TX_1_bw[3]={53, 48, 0};
SPYWORD __MAT2H_RF_FRONT_TX_1_Coeff[2]={1.000000F, 0.000000F};
char __MAT2H_RF_FRONT_TX_2_bw[4]={49, 48, 48, 0}; ########################################################## and the header files contains
#ifndef M2HPHYRFFRONTTX_H #define M2HPHYRFFRONTTX_H namespace M2HPhyRfFrontTx {
typedef struct { char *bw; UINT16 I; UINT16 MemSpS; UINT16 Len; SPYWORD Delay; SPYWORD *Coeff; UINT16 MemLen; } RF_Front_Tx_DB;
const int RF_FRONT_TXS_LEN=4; extern RF_Front_Tx_DB RF_FRONT_TXS[4];
} // End Of Namespace M2HPhyRfFrontTx
#endif
######################################################### I have several files like that, I pass several MAT files to a C++ files.
I have recognized when I add a few files of database on C++ I am getting the following message :
Invalid MEX-file 'M:\...\mxProject.dll': 'M:\...\mxProject.dll' is not a valid Win32 application.
Please help me.
All the memory allocation are static in my database files.
Thanks, Shai All
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
a friend of mine has written this code where he generates a dll in vc++ complier 6.0 .he links successfully with all libs he needs to generate the dll.this dll had a mexFunction entry point, which somehow gives him an error when he tries to use this dll in matlab command prompt.the error message he gets is
Mex file entry point is missing. Please check the (case-sensitive) spelling of mexFunction (for C MEX-files), or the (case-insensitive) spelling of MEXFUNCTION (for FORTRAN MEX-files). ??? Invalid MEX-file 'C:\Program Files\OpenCV\samples\c\krishna\LK\Debug\LK.dll': The specified module could not be found.
.
his code where he generates the dll looks like this.he is successfully able to link and generate the dll using VC++ 6.0. he uses matlab R14. could anyone help ir comment on this problem.
#include "mex.h" #include "cv.h" #include "highgui.h" #include "cxcore.h" #include "stdio.h"
void mexFunction( int nlhs, // Number of left hand side (output) arguments mxArray *plhs[], // Array of left hand side arguments int nrhs, // Number of right hand side (input) arguments const mxArray *prhs[] // Array of right hand side arguments ) {
/* Check for proper number of arguments. */ if (nrhs != 1 && nrhs != 2 && nrhs != 3) { mexErrMsgTxt("One, two, or three inputs required."); } else if (nlhs > 2) { mexErrMsgTxt("Too many output arguments"); }
double *image1,*image2,*velocity_x,*velocity_y,*velox, *veloy; int imysize1,imxsize1,imysize2,imxsize2 ; int dim[2],i,j,size[2]; int x,y; unsigned char *im_1,*im_2; im_1 = (unsigned char *)mxGetData(prhs[0]); im_2 = (unsigned char *)mxGetData(prhs[1]);
// printf("the value is %c",im_1[2]);
/* Assign pointers to first input image*/ //image1 = mxGetPr(prhs[0]); imysize1 = mxGetM(prhs[0]); imxsize1 = mxGetN(prhs[0]); printf("Input image 1: number of columns: %d, number of rows:%d \n",imxsize1,imysize1); int no_rows1 = imysize1; int no_col1 = imxsize1; int width = no_col1; int height = no_rows1;
/* Assign pointers to second input image*/ //image2 = mxGetPr(prhs[1]); imysize2 = mxGetM(prhs[1]); imxsize2 = mxGetN(prhs[1]); printf("Input image 2: number of columns: %d, number of rows:%d \n",imxsize2,imysize2); int no_rows2 = imysize2; int no_col2 = imxsize2; /* for(y=0;y { for(x=0;x { //image1_[y+x*columns1] = int ((image1[y+x*columns1])*255); //image2_[y+x*columns1] = int ((image2[y+x*columns1])*255); //printf("value at %d and %d is %f\n",x,y,((image1[y+x*columns1]))); } }*/
//printf("size %d",sizeof(image1_)); // printf("columns %d\n",columns1);
/* first image converted to 8 bit value*/ CvMat *image_1 = cvCreateMatHeader(no_rows1,no_col1,CV_8UC1); cvSetData(image_1,im_1,(width*1)); /* second image converted to 8 bit value*/ CvMat *image_2 = cvCreateMatHeader(no_rows1,no_col1,CV_8UC1); cvSetData(image_2,im_2,(width*1));
//CvSize size = cvGetSize(image_2); //printf("width %d height %d",size.width, size.height); //gives correct value // printf("\n creation of image headers done\n");
/* for(x=0;x { for(y=0;y { //unsigned char c= im_1[x+y*width]; //unsigned char c1= im_2[x+y*width]; image_1->data.ptr[x+y*width] = c; image_2->data.ptr[x+y*width] = c1; } }*/ // printf("\n assignment done\n"); //printf("value at 0 and 0 is %f\n",CV_MAT_ELEM(*image_2,double,0,0)); /* works fine*/ //printf("the unchar pointer value at 0 and 0 is %d\n",(image_2->data.ptr[241])); //printf("step is %d \n",image_2->step);
/*creation of velocity headers*/
CvMat* velx= cvCreateMatHeader(no_rows1,no_col1,CV_32FC1); cvCreateData(velx);
CvMat* vely= cvCreateMatHeader(no_rows1,no_col1,CV_32FC1); cvCreateData(vely);
/*creation of other required parameters*/
const bool use_previous = false; const double LAMBDA = 100.0f; CvTermCriteria criteria;
criteria.type = CV_TERMCRIT_ITER; criteria.max_iter = 64; criteria.epsilon = 0.01f;
// printf("\n All assignment done\n"); cvCalcOpticalFlowLK(image_1,image_2,cvSize(7,7),velx,vely); //cvCalcOpticalFlowHS(image_1,image_2,use_previous,velx,vely,LAMBDA,criteria);
// printf("\n lucas kanade done"); dim[0] = imysize1; dim[1] = imxsize1; plhs[0] = mxCreateNumericArray(2,dim,mxDOUBLE_CLASS, mxREAL); velocity_x = mxGetPr(plhs[0]); plhs[1] = mxCreateNumericArray(2,dim,mxDOUBLE_CLASS, mxREAL); velocity_y = mxGetPr(plhs[1]);
//printf("Velocity %f \n",CV_MAT_ELEM(*velx,float,5,5));
CvSize size_vel = cvGetSize(velx); // printf("velocity size width %d height %d \n",size_vel.width,size_vel.height);
for(x=0;x { for(y=0;y { velocity_x[x+y*width] = velx->data.fl[x+y*width]; velocity_y[x+y*width] = vely->data.fl[x+y*width];
//velocity_x[y+x*columns1] = CV_MAT_ELEM(*velx,float,x,y); //velocity_y[y+x*columns1] = CV_MAT_ELEM(*vely,float,x,y); //printf("%f\n",velocity_x[y+x*columns1]); } }
}
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi, I'm doing research in TDD(Test Driven Development) in embedded systems. That means writing tests first, and then coding. Right now I am writing some tests for algorithms in MATLAB, and if I want to use the same tests in embedded environment, exp: in C++, the only way is to use MEX file? And I think the translation can only be done manually, not automaticly. I don't know whether my understanding is correct. Thanks a lot.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
For Mr.Riazi
I have tried to do the compute prime example. but i could not create the dll successfully. The following are the error messages i recd.
D:\myprojects\mexfunction\mexfunction.cpp(4) : fatal error C1083: Cannot open precompiled header file: 'Debug/mexFunction.pch': No such file or directory Error executing cl.exe.
Please let me know where i could be wrong. Actually i have used the source code given by you without any change and followed the steps as per your webpage information.
With regards Sekar
|
| Sign In·View Thread·PermaLink | 1.33/5 (2 votes) |
|
|
|
 |
|