Unspecified number of dimension for ndgrid
2 次查看(过去 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!
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!