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 日
What is the size of the result?

回答 (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