Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Creating a 3 Dimensional Array with Elements Automatically Filled In

1 visualización (últimos 30 días)
saad khalid
saad khalid el 14 de Jul. de 2015
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I'm trying to create a 3 Dimensional array. The program I'm running has 3 inputs. "a" needs to go from .08 and .12 in increments of .01, "b" needs to go from 4 to 6 in increments of 1, and "c" needs to go from .7 to .9 in increments of .1. I thought this would be simple enough simply using the colon operator, but I'm having a hard time with this.
I know this could also be done with 3 for loops, however, I think that using a premade matrix with the values will be faster? In case I wasn't clear, the idea is for the program to run with a = .08, b = 4, and c = .7, and then it will increment c to .8 and then .9, and then it will increment b to 5, and start with c = .7 again, until it has gone through all of these cases up to a = .12.
Thank you!

Respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 14 de Jul. de 2015
Editada: Azzi Abdelmalek el 14 de Jul. de 2015
Maybe you need to use meshgrid function
a=0.8:0.1:1.2
b=4:1:6
c=0.7:0.1:0.9
[x,y,z]=meshgrid(a,b,c)
out=[x(:) y(:) z(:)]

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by