Skip to main content
GameDev.net gamedev.net
🔒 Locked

Matlab7 question

Started by The C modest god Jan 21, 2006 at 8:06 AM 2 replies 450+ views
Original Post
The C modest god
The C modest god
I want to have a 2D matrix which each cell of the matrix is a linked list. Is this possible in mathlab?
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
erissian
erissian
I don't think you could use it without writing a little custom script, but I don't see why a matrix couldn't hold memory addresses instead of values. I just wouldn't expect the standard operations to handle it gracefully.

Then again, maybe you could make it work.

Good luck!
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Brother Bob
Brother Bob
The closest thing to that using what MATLAB provides is a cell matrix of vectors. There are no linked lists in MATLAB, and writing your own in MATLAB script is nothing I recomend. It's going to be really messy, as MATLAB doesn't have anything similar to pointers or references; only values.

If you really, REALLY, need a linked list structure over a vector structure in MATLAB, I strongly suggest you write one yourself in C or C++ and compile into a MEX-file.

The cell matrix is created and accessed like this.
>> A=cell(2, 3)A =      []     []     []     []     []     []

A is now a 2 by 3 cell matrix. Initially all elements are empty vectors.
>> A{2,2} = [1 2 3 4]A =      []              []     []     []    [1x4 double]     []

Use {} to access cells, not () as with arrays, and each cell is an independent entity. Each cell can contain different types (strings, vectors, nested cell matrices, aything), and of different size aswell.
erissian
erissian
There are some common extensions that add linked list functionality to matlab.

For instance: http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=212&objectType=file
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.