Create a mesh with four variables

Hello,
I've got my x, y and z components which contain four variables. I would like to know if there is a matlab function, similar to meshgrid, which creates a 4^n x 4^n matrix.
Thank you
Ben

 채택된 답변

Honglei Chen
Honglei Chen 2012년 8월 6일

0 개 추천

댓글 수: 1

Walter Roberson
Walter Roberson 2012년 8월 6일
편집: Walter Roberson 2012년 8월 6일
Maybe, but the output size would seem to be entirely wrong. ndgrid() would be used to create an (n x n x n x n) = n^4 array, not a 4^n x 4^n array.
[C1, C2, C3, C4] = ndgrid(component1_values, component2_values, component3_values, component4_values);
x = f1(C1, C2, C3, C4);
y = f2(C1, C2, C3, C4);
z = f3(C1, C2, C3, C4);
For example,
x = C1.^3 - 5*C2.^2 + cos(C3) - arctan(C4);

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

kawak
kawak 2012년 8월 6일

0 개 추천

Thank you Honglein Chen for your answer,
However I don’t think that ndgrid() will create a full grid.
For example, if you tape the following commands
>> [X1,X2,X3,X4] = ndgrid(0:1:2); >> A=[X1 X2 X3 X4]
You will see that the mesh A does not have the point A=0 0 0 0.
Thanks
Ben

댓글 수: 2

Honglei Chen
Honglei Chen 2012년 8월 6일
편집: Honglei Chen 2012년 8월 6일
Hi Kawak,
You are not reading the result correctly. For example, X1 here is a 4-dimensional array. So to look for a given point, you need to find the corresponding element in each of these four matrices. For example
>> [X1(1,1,1,1) X2(1,1,1,1) X3(1,1,1,1) X4(1,1,1,1)]
ans =
0 0 0 0
kawak
kawak 2012년 8월 6일
Ah ok.. :-) Thanks a lot Chen, it does work now.
Thanks again

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2012년 8월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by