From: Frederic PETITPRES on 12 Jul 2010 12:06 In fact, I have to translate FORTRAN code into Matlab code. My fortan code is divided into three files. There is the main program. Then a file where the variables are defined. The variables are structures containing a lot of parameters. A file contains every function I need in my main (several Subroutines). How could I translate the following stuff (which is used in the declaration of variables)? TYPE droplets Real :: X,Y TYPE(droplets), POINTER :: next TYPE(droplets), POINTER :: prev END TYPE droplets Moreover, I was wondering if I could create a M-file to define my new types? Thank you in advance :)
From: James Tursa on 12 Jul 2010 12:30 "Frederic PETITPRES" <frederic.petitpres(a)hotmail.fr> wrote in message <i1fehc$q7$1(a)fred.mathworks.com>... > > How could I translate the following stuff (which is used in the declaration of variables)? > > TYPE droplets > Real :: X,Y > TYPE(droplets), POINTER :: next > TYPE(droplets), POINTER :: prev > END TYPE droplets > > Moreover, I was wondering if I could create a M-file to define my new types? Looks like a linked list. However, MATLAB does not have a pointer type, so you cannot implement this directly in MATLAB. As an alternative, you could look at what others have done to emulate this capability. e.g., http://www.mathworks.com/matlabcentral/fileexchange/25179-pointers-toolbox James Tursa
From: dpb on 12 Jul 2010 13:53 Frederic PETITPRES wrote: > In fact, I have to translate FORTRAN code into Matlab code. > My fortan code is divided into three files. There is the main program. > Then a file where the variables are defined. The variables are > structures containing a lot of parameters. A file contains every > function I need in my main (several Subroutines). > > How could I translate the following stuff (which is used in the > declaration of variables)? > > TYPE droplets > Real :: X,Y > TYPE(droplets), POINTER :: next > TYPE(droplets), POINTER :: prev > END TYPE droplets > > Moreover, I was wondering if I could create a M-file to define my new > types? > Thank you in advance :) Alternatively to James' suggestion, what about leaving the Fortran as Fortran and building a link to it from Matlab? --
From: Frederic PETITPRES on 12 Jul 2010 15:53 Thanks for your answer. I think it could be very useful. But I am wondering what the matlab function libpointer is ? Then, I would like to know where can I define my new types of variable (like droplets)? In a M-file? Because they appear in several functions. "James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <i1ffv1$57v$1(a)fred.mathworks.com>... > "Frederic PETITPRES" <frederic.petitpres(a)hotmail.fr> wrote in message <i1fehc$q7$1(a)fred.mathworks.com>... > > > > How could I translate the following stuff (which is used in the declaration of variables)? > > > > TYPE droplets > > Real :: X,Y > > TYPE(droplets), POINTER :: next > > TYPE(droplets), POINTER :: prev > > END TYPE droplets > > > > Moreover, I was wondering if I could create a M-file to define my new types? > > Looks like a linked list. However, MATLAB does not have a pointer type, so you cannot implement this directly in MATLAB. As an alternative, you could look at what others have done to emulate this capability. e.g., > > http://www.mathworks.com/matlabcentral/fileexchange/25179-pointers-toolbox > > James Tursa
From: dpb on 12 Jul 2010 16:29 Frederic PETITPRES wrote: ....please don't top post. Makes hard conversation follow very... > Thanks for your answer. I think it could be very useful. > But I am wondering what the matlab function libpointer is ? > > Then, I would like to know where can I define my new types of variable > (like droplets)? In a M-file? Because they appear in several functions. .... Since the code uses UDTs, it's obviously F90+ and so I presume the variables are module scope given the tone of the question (crystal seems to be working again at least temporarily). In Matlab, unfortunately, there's no such scoping mechanism other than GLOBAL (which another reason I suggested the alternative of leaving the Fortran code in Fortran and having an interface to it. Of course, that is into an area that the crystal ball isn't helping with and that is the reason for the conversion to Matlab in the first place which would determine what is/is not viable solution other than a complete rewrite, if any. --
|
Next
|
Last
Pages: 1 2 Prev: Storing Data from XPC Target Next: Add Customized Function in Fuzzy Toolbox |