Create a Matrix with Specific Pattern for Changing Values

2 views (last 30 days)
How can I create a matrix such as this one where the change in value is some dx and each column varies differently?
[-3*pi/4 -3*pi/4 -3*pi/4;
-3*pi/4 -3*pi/4 -3*pi/8;
-3*pi/4 -3*pi/4 0;
-3*pi/4 -3*pi/8 -3*pi/4;
-3*pi/4 -3*pi/8 -3*pi/8;
-3*pi/4 -3*pi/8 0;
-3*pi/4 0 -3*pi/4;
-3*pi/4 0 -3*pi/8;
-3*pi/4 0 0;
-3*pi/8 -3*pi/4 -3*pi/4;
-3*pi/8 -3*pi/4 -3*pi/8;
-3*pi/8 -3*pi/4 0;
-3*pi/8 -3*pi/8 -3*pi/4;
-3*pi/8 -3*pi/8 -3*pi/8;
-3*pi/8 -3*pi/8 0;
-3*pi/8 0 -3*pi/4;
-3*pi/8 0 -3*pi/8;
-3*pi/8 0 0;
0 -3*pi/4 -3*pi/4;
0 -3*pi/4 -3*pi/8;
0 -3*pi/4 0;
0 -3*pi/8 -3*pi/4;
0 -3*pi/8 -3*pi/8;
0 -3*pi/8 0;
0 0 -3*pi/4;
0 0 -3*pi/8;
0 0 0]

Answers (1)

Kelly Kearney
Kelly Kearney on 16 Apr 2019
Create a grid of values, then unwrap:
xval = [-3*pi/4 -3*pi/8 0];
[a,b,c] = ndgrid(x,x,x);
x = [c(:) b(:) a(:)]

Categories

Find more on Data Types in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!