Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Creating a 3 Dimensional Array with Elements Automatically Filled In

조회 수: 1 (최근 30일)
saad khalid
saad khalid 2015년 7월 14일
마감: MATLAB Answer Bot 2021년 8월 20일
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!

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 14일
편집: Azzi Abdelmalek 2015년 7월 14일
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