Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Variable addresses?

Subject: Variable addresses?

From: Eric

Date: 11 Jul, 2007 15:24:03

Message: 1 of 5

Hello -

    Is it possible to get Matlab to display the hexadecimal address of Workspace variables? I'm teaching Matlab programming to mathematical biology students, and since they have no programming experience at all, I would like to show them exactly what's happening when they create/initialize variables.

    Thanks in advance.

Eric

Subject: Variable addresses?

From: Michael Wild

Date: 11 Jul, 2007 17:35:33

Message: 2 of 5

Eric wrote:
> Hello -
>
> Is it possible to get Matlab to display the hexadecimal address of Workspace variables? I'm teaching Matlab programming to mathematical biology students, and since they have no programming experience at all, I would like to show them exactly what's happening when they create/initialize variables.
>
> Thanks in advance.
>
> Eric


format debug


but i'm not sure this is something they will/can appreciate ;-)

michael

Subject: Variable addresses?

From: Peter Boettcher

Date: 17 Jul, 2007 12:29:14

Message: 3 of 5

"Eric " <toolson@unm.edu> writes:

> Hello -
>
> Is it possible to get Matlab to display the hexadecimal address
> of Workspace variables? I'm teaching Matlab programming to
> mathematical biology students, and since they have no
> programming experience at all, I would like to show them exactly
> what's happening when they create/initialize variables.

Hex addresses have more to do with the implementation of MATLAB and
not the semantics of the language. True, it is important to be
familiar with levels of abstraction lower than the level you're
programming in, but it's hardly the place to start for beginning
programmers... I would stick with the behavior/semantics of the MATLAB
language for the base.

Image teaching C programming, and in the first semester explaining how
malloc works: C library, brk() system call, page faults, difference
between virtual/kernel/physical memory addresses, modification of the
hardware page table, etc. A partial taste of all this stuff is
probably worse than a simple model for how malloc behaves, followed by
a later class in operating systems.

Just my (NS)HO

-Peter

Subject: Variable addresses?

From: Yair Altman

Date: 21 Jul, 2007 21:09:49

Message: 4 of 5

>> Is it possible to get Matlab to display the hexadecimal address of Workspace variables?
>
> format debug


Michael - this is very interesting (and entirely undocumented) - thanks for sharing. Can you please elaborate on the entries displayed by this debug format (and perhaps other undocumented format options)?

>> pi
ans =

Structure address = 102ad690
m = 1 => # rows
n = 1 => # cols
pr = 11287160 => OS/JVM thread id?
pi = 0 => ???
    3.1416

Yair Altman
http://www.ymasoftware.com

Subject: Variable addresses?

From: Doug Schwarz

Date: 21 Jul, 2007 21:32:53

Message: 5 of 5

In article <f7tsms$m4r$1@fred.mathworks.com>,
 "Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote:

> >> Is it possible to get Matlab to display the hexadecimal address of
> >> Workspace variables?
> >
> > format debug
>
>
> Michael - this is very interesting (and entirely undocumented) - thanks for
> sharing. Can you please elaborate on the entries displayed by this debug
> format (and perhaps other undocumented format options)?
>
> >> pi
> ans =
>
> Structure address = 102ad690
> m = 1 => # rows
> n = 1 => # cols
> pr = 11287160 => OS/JVM thread id?
> pi = 0 => ???
> 3.1416
>
> Yair Altman
> http://www.ymasoftware.com

pr is just the pointer to the block of memory containing the real part
of the array. pi is the same for the imaginary part, 0 (null pointer)
meaning that the array has no imaginary part.

--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us