Matlab7 question

Started by
2 comments, last by erissian 18 years, 3 months ago
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:Original post by The C modest godHow is my improoved signature?It sucks, just like you.
Advertisement
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)
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.
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)

This topic is closed to new replies.

Advertisement