I want to make a 3x3 matrix of cartesian data points (x,y) such that the matrix would have the form of
A = [(0,0) (0,1) (0,2); (1,0) (1,1) (1,2); (2,0) (2,1) (2,2)]
What would be the syntax to make this possible because right now I keep getting stuck with a 3x6 matrix when I try to implement it?

 Réponse acceptée

Jos (10584)
Jos (10584) le 14 Juil 2017
You can create a 3D matrix:
[xx,yy] =meshgrid(0:2)
A = cat(3,xx,yy)
so that A(:,:,k) gives you a specific k-th point in space.
or you can create a cell array C , so that C{k} holds that point
C = arrayfun(@(k) [xx(k) yy(k)],1:numel(xx),'un',0)

Plus de réponses (0)

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by