How to store a domain in a matrix?

9 vues (au cours des 30 derniers jours)
Jacob
Jacob le 11 Avr 2014
Commenté : Jacob le 11 Avr 2014
With this domain:
xcoords=-0.2:0.01:1.2; (numel(xcoords)=141)
ycoords=-0.7:0.1:0.7; (numel(ycoords)=15)
How can i store all the points 2115 points(x,y) of the domain in a an array(2115,2)?

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 11 Avr 2014
xcoords=-0.2:0.01:1.2;
ycoords=-0.7:0.1:0.7;
[x,y]=meshgrid(xcoords,ycoords);
out=[x(:) y(:)];
size(out)
  1 commentaire
Jacob
Jacob le 11 Avr 2014
Thank you, that is exact!

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 11 Avr 2014
[X, Y] = ndgrid(xcoords, ycoords);
DesiredArray = [X(:), Y(:)];

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by