Unspecified number of dimension for ndgrid

1 次查看(过去 30 天)
Hello,
I want to produce a space with N number of dimensions using ndgrid where N will depend on another part of the program. The thing is, depending on an earlier section of the progrm N can be any integer starting from 1 but N is known at this point; it's just not constant. Therefore I can't just set the specified domain into ndgrid, say [X,Y,Z]= ndgrid(x,y,z) where x,y,z = 0:0.1:10.
The next part of code is how it is supposed to look if N was constant:
x1=0:0.1:10; x2=0:0.1:10;
domain = {x1,x2};
[X1,X2] = ndgrid(domain{1,1},domain{1,2});
I was thinking of somehow implementing a for loop which would increase ndgrid(domain{1,1},domain{1,2},...,domain{1,n}) until n=N. But I'm quite stuck.
The other thing is that X1,X2,... would have to increase to N to keep the number of dimensions constant.
Thank you!

采纳的回答

Torsten
Torsten 2023-7-5

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by