MATLAB: How to arrange coordinates into 3 columns

matrix manipulationmesh

I'm creating the mesh of a wing, so, in order to export the coordinates of each node I need to arrange all the coordinates (x,y,z) into three columns.
By the moment I have agrouped the coordinates into three section, each one correspont to each coordinate. But I would like to organize them in such a way that each column continues to be a single column until the last one corresponding to that coordinate (x or y or z). I hope I have explained myself, I also attached an image and the code.Thanks in advance
150519 Orden de columnas.png
function WINGEODISC
%% Read airfoil
FILEID = fopen('A_prof.txt','r');
FORMATSPEC = '%f %f'; % %d times should correspont to m
SIZEXZ = [3 Inf]; % [m,n] n can be Inf, but m cannot.
XZ = fscanf(FILEID,FORMATSPEC,SIZEXZ);
fclose(FILEID);
XZ = XZ';
XP_AIRFOIL = XZ(:,1);
ZP_AIRFOIL = XZ(:,2);
%% Wing definitions
MAIN_NODES_X = ones(4,4);
%SPAN = 10;
AREA = 7.5;
AR = 13.3333;
LE_SWEPT = 30; % Swept wing - Стреловидность - Flechamiento [deg]
%TE_SWEPT = 0; % Trailing edge
TAPER = 2;
SEMISPAN = sqrt(AR*AREA)/2;
CHORD_ROOT = 2*AREA*TAPER/(TAPER+1)/SEMISPAN
CHORD_TIP = CHORD_ROOT/TAPER;
MAIN_NODES_X = [0 CHORD_ROOT; tan(degtorad(LE_SWEPT)) CHORD_TIP+tan(degtorad(LE_SWEPT))]
MAIN_NODES_Y = [0 0; SEMISPAN SEMISPAN]
%% Wing discretization
%
NX = 13;
NY = 3;
XP_NODES = ones(NY,NX);
YP_NODES = ones(NY,NX);
ZP_NODES = ones(NY,NX);
DELTA_LX = CHORD_ROOT/NX;
DELTA_LY = SEMISPAN/NY;
XP_NODES(1,:) = linspace(0,CHORD_ROOT,NX).*XP_AIRFOIL';
ZP_NODES(1,:) = CHORD_ROOT*XZ(:,2)';
%ZP_NODES(1,:) = linspace(0,CHORD_ROOT,NX).*ZP_AIRFOIL';
%XP_NODES(1,:) = XP_NODES(1,:).*XP_AIRFOIL'
XP_NODES(end,:) = linspace(0,CHORD_TIP,NX)+tan(degtorad(LE_SWEPT)).*XP_AIRFOIL';
%XP_NODES = linspace(0,CHORD_TIP)
ZP_NODES(end,:) = CHORD_TIP.*XZ(:,2)';
MESH = [XP_NODES' YP_NODES' ZP_NODES']
%%
%}
end

Best Answer

If you want to linearize an array, you can use (:):
[XP_NODES,YP_NODES,ZP_NODES]=deal(XP_NODES',YP_NODES',ZP_NODES');
MESH = [XP_NODES(:) YP_NODES(:) ZP_NODES(:)];