Create a Matrix with Specific Pattern for Changing Values

2 visualizaciones (últimos 30 días)
Allison Bushman
Allison Bushman el 16 de Abr. de 2019
Respondida: Kelly Kearney el 16 de Abr. de 2019
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]

Respuestas (1)

Kelly Kearney
Kelly Kearney el 16 de Abr. de 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(:)]

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by