I am writing a matlab program in which I am trying to create
I am writing a matlab program in which I am trying to create a plot from a set of arrays which will be a series of line segments each with its own line thickness. There is a x array and a y array for the staring point and a x array and a y array for the ending point and a fifth array that gives a the line thick ness for each line segment.
Example:
x1=[0 10 10 0] y1=[0 0 2 2] x2=[10 10 0 0] y2=[0 2 2 0]
thickness=[0.1 0.4 0.2 0.1]
How do I do this?
Solution
Multidimensional arrays in MATLAB are created the same way as two-dimensional arrays. For example, first define the 3 by 3 matrix, and then add a third dimension.
A = [5 7 8; 0 1 9; 4 3 6]; A(:,:,2) = [1 0 4; 3 5 6; 9 8 7]
 A = (:,:,1) =      5     7     8      0     1     9      4     3     6 (:,:,2) =      1     0     4      3     5     6      9     8     7
The CAT function is a useful tool for building multidimensional arrays. B = cat(DIM,A1,A2,...) builds a multidimensional array by concatenating A1, A2 ... along the dimension DIM.
B = cat( 3, [2 8; 0 5], [1 3; 7 9], [2 3; 4 6])
 B = (:,:,1) =      2     8      0     5 (:,:,2) =      1     3      7     9 (:,:,3) =      2     3      4     6
Calls to CAT can be nested.
A = cat(3,[9 2; 6 5], [7 1; 8 4]); B = cat(3,[3 5; 0 1], [5 6; 2 1]); C = cat(4,A,B,cat(3,[1 2; 3 4], [4 3; 2 1

