Create a mesh with four variables
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponse acceptée
Honglei Chen
le 6 Août 2012
1 commentaire
Walter Roberson
le 6 Août 2012
Modifié(e) : Walter Roberson
le 6 Août 2012
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);
Plus de réponses (1)
kawak
le 6 Août 2012
2 commentaires
Honglei Chen
le 6 Août 2012
Modifié(e) : Honglei Chen
le 6 Août 2012
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
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!