Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Passing large arrays between functions
Replies: 2   Last Post: Sep 5, 2013 2:18 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Loren Shure

Posts: 1,015
Registered: 12/7/04
Re: Passing large arrays between functions
Posted: Sep 5, 2013 1:29 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"IceHaven " <alanlelandchan@gmail.com> wrote in message
> Hi,
> I'm looking for a way to pass large arrays between functions without using
> globals. I have a script that analyzes lots of data, and i want to create
> a function that's sole purpose is to graph this data (and in turn
> centralize what data is graphed and what isn't).
> I know that I can do this by making a ton of global arrays, but this is
> obviously a dangerous solution. The other solution I can think of is
> somehow passing the arrays to another workspace, then pulling that
> workspace into the graphing function. I'm not sure how that would work
> though.
> Is there a way to gather large arrays from different functions and scripts
> without using globals?
> thanks!

Glad you don't care for the global data idea!

If you simply pass the arrays but don't alter them, a real copy is never
made. However, a copy is always made to hold within plots. Since copies
aren't made if the arrays aren't being updated, simply send your large
arrays in as input arguments.

The documentation has a bunch of information on memory as does this blog
post of mine:



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.