Create a Matrix with Specific Pattern for Changing Values

2 visualizzazioni (ultimi 30 giorni)
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]

Risposte (1)

Kelly Kearney
Kelly Kearney il 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(:)]

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by