flexcookie
flexcookie

Reputation: 113

Construct an array where each element is also an array

I'm a bit new to matlab, so please bear with me, I'm not 100% sure if what I want to do can actually be done.

So, I have an array

coords = zeros(2000, 2);

and another array representing the actual coordinates

pixCoords = [35 200] %dummy values

How can I/ what is the syntax to assign pixCoords to the (1,1) position of coords, such that when I type in coords(1,1) the console will return 35 200?

Eventually, each column of coords will have two different sets of coordinates in them.

Thanks!

Upvotes: 1

Views: 37

Answers (1)

Ulf Aslak
Ulf Aslak

Reputation: 8608

I believe cell arrays are your friends here.

coords = {};
coords{1, 1} = [35 200];

% now you want to retrieve the array
coords{1, 1}
% ans = 
%    35   200

And you can of course add new arrays to other positions in your cell array using the same notation.

Upvotes: 2

Related Questions