Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Creating a 3 Dimensional Array with Elements Automatically Filled In

1 Ansicht (letzte 30 Tage)
saad khalid
saad khalid am 14 Jul. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 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!

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 14 Jul. 2015
Bearbeitet: Azzi Abdelmalek am 14 Jul. 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(:)]

Community Treasure Hunt

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

Start Hunting!

Translated by