Create a Matrix with Specific Pattern for Changing Values

2 次查看(过去 30 天)
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]

回答(1 个)

Kelly Kearney
Kelly Kearney 2019-4-16
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(:)]

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by