1

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!

1
  • 3
    If every element of your desired array will have a 2 element vector, you probably just want to use a 3D matrix here rather than cell arrays. They're much easier to work with in MATLAB Commented Apr 7, 2016 at 7:04

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.