From: James Tursa on 8 Jun 2010 20:24 "George " <guanjihou(a)gmail.com> wrote in message <humlki$7ub$1(a)fred.mathworks.com>... > > Regarding to why I am using > > integer*4 plhs(*), prhs(*) > > instead of mwPointer plhs(*), prhs(*), > > When I use the latter one, there are some error in the like, as follow: > > rror: Syntax error, found IDENTIFIER 'PLHS' when expecting one of: ( : % . = => > mwPointer plhs(*), prhs(*) > > I do include the header file, I just can't figure out what is wrong. But when I use the former declaration, this error message would not appear. Do you know why? You are probably using an older version of MATLAB that did not have mwPointer defined in the header file fintrf.h, so in that case using integer*4 is fine. I would instead suggest that you continue to use mwPointer in your code and insert the following at the front of your code: #ifndef mwPointer #define mwPointer integer*4 #endif Same thing for mwSize #ifndef mwSize #define mwSize integer*4 #endif James Tursa
From: George on 8 Jun 2010 23:44 "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hummrd$pua$1(a)fred.mathworks.com>... > "George " <guanjihou(a)gmail.com> wrote in message <humk70$6jm$1(a)fred.mathworks.com>... > > > > However, I still have one confusing. The Matlab help stated that mexFunction() is not a function that I can call. I am using fortran, so it is just a subroutine. My question is how can I call this subroutine in my main program? > > > > Suppose that I have the following main program: > > > > #include "fintrf.h" > > program TestmexCallMatlab > > Call mexCallfunction(1,1,1,1) > > end > > > > I tried, but it seems that I can't do this. So could you please tell me how to do this? > > You can't. mexFunction is a gateway routine that MATLAB calls when you invoke the function from MATLAB. It is not something you call yourself. > > James Tursa Thanks James, So what do I do if I want to call a Matlab function or m file in my main Fortran program? Shall I use the engCallMatlab? Thanks very much!
From: George on 8 Jun 2010 23:50 "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hummv6$41g$1(a)fred.mathworks.com>... > "George " <guanjihou(a)gmail.com> wrote in message <humlki$7ub$1(a)fred.mathworks.com>... > > > > Regarding to why I am using > > > > integer*4 plhs(*), prhs(*) > > > > instead of mwPointer plhs(*), prhs(*), > > > > When I use the latter one, there are some error in the like, as follow: > > > > rror: Syntax error, found IDENTIFIER 'PLHS' when expecting one of: ( : % . = => > > mwPointer plhs(*), prhs(*) > > > > I do include the header file, I just can't figure out what is wrong. But when I use the former declaration, this error message would not appear. Do you know why? > > You are probably using an older version of MATLAB that did not have mwPointer defined in the header file fintrf.h, so in that case using integer*4 is fine. I would instead suggest that you continue to use mwPointer in your code and insert the following at the front of your code: > > #ifndef mwPointer > #define mwPointer integer*4 > #endif > > Same thing for mwSize > > #ifndef mwSize > #define mwSize integer*4 > #endif > > > James Tursa James, Yes, I did try this method before, but it is the same situation. Also I have checked the header file, the variable declarations are there. It is really confusing. Thanks.
From: James Tursa on 9 Jun 2010 00:53 "George " <guanjihou(a)gmail.com> wrote in message <hun31c$6e$1(a)fred.mathworks.com>... > "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hummv6$41g$1(a)fred.mathworks.com>... > > "George " <guanjihou(a)gmail.com> wrote in message <humlki$7ub$1(a)fred.mathworks.com>... > > > > > > Regarding to why I am using > > > > > > integer*4 plhs(*), prhs(*) > > > > > > instead of mwPointer plhs(*), prhs(*), > > > > > > When I use the latter one, there are some error in the like, as follow: > > > > > > rror: Syntax error, found IDENTIFIER 'PLHS' when expecting one of: ( : % . = => > > > mwPointer plhs(*), prhs(*) > > > > > > I do include the header file, I just can't figure out what is wrong. But when I use the former declaration, this error message would not appear. Do you know why? > > > > You are probably using an older version of MATLAB that did not have mwPointer defined in the header file fintrf.h, so in that case using integer*4 is fine. I would instead suggest that you continue to use mwPointer in your code and insert the following at the front of your code: > > > > #ifndef mwPointer > > #define mwPointer integer*4 > > #endif > > > > Same thing for mwSize > > > > #ifndef mwSize > > #define mwSize integer*4 > > #endif > > > > > > James Tursa > > James, > > Yes, I did try this method before, but it is the same situation. > Also I have checked the header file, the variable declarations are there. It is really confusing. > > Thanks. The pre-processor is case sensitive. So double check that your fintrf.h file to see if mwpointer, MWPOINTER, or mwPointer etc is defined. You can also insert the following: #ifndef mwpointer #define mwpointer integer*4 #endif #infndef MWPOINTER #define MWPOINTER mwpointer #endif #ifndef mwPointer #define mwPointer mwpointer #endif and similar for mwSize. What version of MATLAB are you using? James Tursa
From: James Tursa on 9 Jun 2010 01:00 "George " <guanjihou(a)gmail.com> wrote in message <hun2m4$7nk$1(a)fred.mathworks.com>... > "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hummrd$pua$1(a)fred.mathworks.com>... > > "George " <guanjihou(a)gmail.com> wrote in message <humk70$6jm$1(a)fred.mathworks.com>... > > > > > > However, I still have one confusing. The Matlab help stated that mexFunction() is not a function that I can call. I am using fortran, so it is just a subroutine. My question is how can I call this subroutine in my main program? > > > > > > Suppose that I have the following main program: > > > > > > #include "fintrf.h" > > > program TestmexCallMatlab > > > Call mexCallfunction(1,1,1,1) > > > end > > > > > > I tried, but it seems that I can't do this. So could you please tell me how to do this? > > > > You can't. mexFunction is a gateway routine that MATLAB calls when you invoke the function from MATLAB. It is not something you call yourself. > > > > James Tursa > > Thanks James, > > So what do I do if I want to call a Matlab function or m file in my main Fortran program? Shall I use the engCallMatlab? Yes, you can use the engCallMATLAB function that I have on the FEX since this is not a MATLAB supplied routine. Be aware of some penalties involved, however. A mexFunction acts as a subroutine to MATLAB itself. You can basically pass variables back and forth by reference so it is generally quite efficient to call an m-file from within the routine. The downside is you can't use read(*,__) and write(*,__) in your code, you have to use mexPrintf. A program has to *copy* everything back & forth between your program and the MATLAB engine, so you incur all of the inefficiencies of the extra data copies floating around in memory as well as the extra time involved in doing the copying. The upside is you can use read(*,__) and write(*,__) in your code. James Tursa
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: 2d interpolation of an image Next: how i can calculate inverse TFD (log (Matrix(k, n))) |