Re: pass 1D vector from matlab to fortran
- From: James Tursa <aclassyguywithaknotac@xxxxxxxxxxx>
- Date: Mon, 31 Dec 2007 09:04:19 GMT
On Mon, 31 Dec 2007 07:16:03 +0000 (UTC), "Eric Jäger"
<eric.jaeger.nospam@xxxxxxxxxxxxx> wrote:
I only have an example code for passing a 2D matrix from
matlab to fortran (and then again back to matlab):
plhs(1)=mxCreateNumericArray(2,[10;100],mxClassIDFromClassName('double'),0)
output1=mxGetPr(plhs(1))
%Call Fortran code
call_stl(%val(input1),%val(input2),%val(output1))
How do I have to change the code to pass an 1D vector (lets
say size: 1*1000) from matlab to fortran?
If you have working code for a 2D matrix, you should be able to just
replace the dimension values 10 & 100 with your new values 1 & 1000
and it should work just fine, even if the Fortran variable is only one
dimension. A 1D variable in MATLAB is treated as 2D with one of the
dimensions 1 (a scalar is a 2D with both of the dimensions 1). You
don't show much code for your example so I can't give you specific
advice. What are input1 and input2? Are they the result of another
mxGetPr call somewhere in your code? Is your call_stl(...) working for
2D? etc. etc.
James Tursa
.
- Follow-Ups:
- Re: pass 1D vector from matlab to fortran
- From: Eric Jäger
- Re: pass 1D vector from matlab to fortran
- References:
- pass 1D vector from matlab to fortran
- From: Eric Jäger
- pass 1D vector from matlab to fortran
- Prev by Date: Alternative to Mathlab for arbitrary precision
- Next by Date: saveas
- Previous by thread: pass 1D vector from matlab to fortran
- Next by thread: Re: pass 1D vector from matlab to fortran
- Index(es):
Relevant Pages
|