Hi all,
For some GPS related calculations, I have a bunch of vectors and variables which are needed in a lot of functions.
The thing is that all those date belong togehter in some way. When I would program in Jave, I would make a class from it.
So, what I did is making a new matlab data type which bundles all this information. I added some functions such that it acts just as a struct: I can acces the columns and the elements. The nice advantage is that I could modify the display function, such that I get a nice overview of the data when omitting the ;
But, when I pass this data type as argument to a function, do some manipulations on it, and want the function to return it, it slows down my program due to call by value.
Is there a way to work with pointers and adresses like is possible in C? Or is there perhaps another solution for my problem?
All hints are really appreciated!
Many thanks,
J.
|
|
0
|
|
|
|
Reply
|
jverhoeve (3)
|
4/12/2008 5:33:27 AM |
|
Jeroen <jverhoeve@hotmail.com> wrote in message
<8902033.1207992837734.JavaMail.jakarta@nitrogen.mathforum.org>...
> Hi all,
>
> For some GPS related calculations, I have a bunch of
vectors and variables which are needed in a lot of functions.
>
> The thing is that all those date belong togehter in some
way. When I would program in Jave, I would make a class from it.
>
> So, what I did is making a new matlab data type which
bundles all this information. I added some functions such
that it acts just as a struct: I can acces the columns and
the elements. The nice advantage is that I could modify the
display function, such that I get a nice overview of the
data when omitting the ;
>
> But, when I pass this data type as argument to a function,
do some manipulations on it, and want the function to return
it, it slows down my program due to call by value.
>
> Is there a way to work with pointers and adresses like is
possible in C? Or is there perhaps another solution for my
problem?
>
> All hints are really appreciated!
>
> Many thanks,
> J.
"Inplace" package in FEX might be what you are looking for:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11290&objectType=file
Warning: reference argument passing is not supported by
Mathworks, and they do anything to discourage users to use them.
Bruno
|
|
0
|
|
|
|
Reply
|
b.luong (628)
|
4/12/2008 10:25:03 AM
|
|
Jeroen <jverhoeve@hotmail.com> wrote in message
<8902033.1207992837734.JavaMail.jakarta@nitrogen.mathforum.
org>...
> Hi all,
>
> For some GPS related calculations, I have a bunch of
vectors and variables which are needed in a lot of
functions.
>
> The thing is that all those date belong togehter in some
way. When I would program in Jave, I would make a class
from it.
>
> So, what I did is making a new matlab data type which
bundles all this information. I added some functions such
that it acts just as a struct: I can acces the columns and
the elements. The nice advantage is that I could modify
the display function, such that I get a nice overview of
the data when omitting the ;
>
> But, when I pass this data type as argument to a
function, do some manipulations on it, and want the
function to return it, it slows down my program due to
call by value.
>
> Is there a way to work with pointers and adresses like
is possible in C? Or is there perhaps another solution for
my problem?
>
> All hints are really appreciated!
>
> Many thanks,
> J.
I recommend you take a look at:
1) Specifying reference behaviour with handle classes in
R2008a:
http://www.mathworks.com/access/helpdesk/help/techdoc/matla
b_oop/brfylwk-1.html
2)How MATLAB's copy-on-write behaviour for value objects
works:
http://blogs.mathworks.com/loren/2006/05/10/memory-
management-for-functions-and-variables/
3)In-place calling behaviour:
http://blogs.mathworks.com/loren/2007/03/22/in-place-
operations-on-data/
Stuart
|
|
0
|
|
|
|
Reply
|
stuart.mcgarrity.nospam (19)
|
4/12/2008 7:10:06 PM
|
|
Jeroen <jverhoeve@hotmail.com> writes:
> Hi all,
>
> For some GPS related calculations, I have a bunch of vectors and
> variables which are needed in a lot of functions.
>
> The thing is that all those date belong togehter in some way. When I
> would program in Jave, I would make a class from it.
>
> So, what I did is making a new matlab data type which bundles all this
> information. I added some functions such that it acts just as a
> struct: I can acces the columns and the elements. The nice advantage
> is that I could modify the display function, such that I get a nice
> overview of the data when omitting the ;
>
> But, when I pass this data type as argument to a function, do some
> manipulations on it, and want the function to return it, it slows down
> my program due to call by value.
>
> Is there a way to work with pointers and adresses like is possible in
> C? Or is there perhaps another solution for my problem?
The only reason I would pursue in-place computation is if you have a
very large dataset, in the hundreds of megabytes. Otherwise, I would
guess that a simple struct array passed in and out of your functions
will do fine.
MATLAB already makes use of call-by-reference, internally, when a
variable (or part of a cell or struct array) is not modified. How have
you determined that call-by-value is the particular cause of your
performance problem?
-Peter
|
|
0
|
|
|
|
Reply
|
boettcher (2302)
|
4/14/2008 1:47:06 PM
|
|
|
3 Replies
82 Views
(page loaded in 0.173 seconds)
Similiar Articles: Difference between passing a number and a variable to a subroutine ...There is no way to get all of the "features" of pass by reference. Given something like a = 47 call xxx(a,a) print *, a .... Pointers to global and stack variables - comp.compilersIn Java this is necessarily a heap pointer - you can't call by reference and you can't point to a non-object. Another use, as was pointed out, is statically constructed ... seg2 read code - comp.soft-sys.matlabI'm a MSc candidate in Geoscience. I need seg2 code in MATLAB. anybody can help me with this? Besides, I need segy code as well. I'm eternally grat... comp.soft-sys.matlab - page 242If Matlab uses call by reference, or call by value etc 2. If Matlab uses reference counting, or mark & sweep garbage collection 3. If the... o.alsaeede (2) 64-bit byteswapping and legacy programs - comp.lang.fortran ...(You can pass an array element to either a scalar dummy or array dummy.) "Call by reference" has a pretty specific meaning, where there is no specific meaning for ... Local array variables in functions - comp.lang.awkArray parameters passed to functions are passed 'by reference' in awk, and changing an ... function definition need not match the number of parameters in the function call. Re: Question From a Brainbench exam - comp.lang.c++.moderated ...... own what they reference (they're only >> references to other variables, as it becomes obvious when you pass >> values by reference for example). >> >> If you need to call ... Passing va_list by reference to a function - comp.lang.c ...How can I pass a va_list to another function by reference? In a simple libc implementation I have some functions as follows: static int xprintf(... arg function in matlab - comp.soft-sys.matlabPassing va_list by reference to a function - comp.lang.c ... Passing integer arguments ... an additional argument for every value you want to pass in a function call, you ... Initialization of reference to non-const - comp.lang.c++.moderated ...After that the attempt to call a function that is non-const (GetSize() is not ... You simply attempted to call a non-const member function through a const reference. Evaluation strategy - Wikipedia, the free encyclopediaIn call-by-reference evaluation (also referred to as pass-by-reference), a function receives an implicit reference to a variable used as argument, rather than a copy of its ... Call by Value and Call by Reference - Self-Study Online TrainingIn C programming language variables can be referred differently depending on the context For example if you are writing a program for a low memory system you may want ... 7/11/2012 10:13:54 AM
|