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!
0 件のコメント
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!