Trying to Loop through different values of two matrixes simultaneously

6 Ansichten (letzte 30 Tage)
Michael Costa
Michael Costa am 16 Okt. 2020
Beantwortet: Matt J am 16 Okt. 2020
I have a program that calculates the grain boundary energy (single output) given inputs of two 3 by 3 matrices, let's call them matrix A and matrix B. These matrices tell the program the relative orientation of two grains in the metal. I need to write another program that optimizes the grain boundary energy by finding the orientation (two matrices) that minimizes the energy. My thought of how to do this is to loop through "all" (starting off i would want each matrix element to start at zero, step by 0.01, and go to say, 10) the values of each matrix element. After all the energies (again, single outputs corresponding to each iteration of inputs A and B) are calculated, I would have MATLAB find the minimum values, say the lowest 50% of energies. So far I can't figure out how to test every combination of the elements of matrix A with every combination of the elements of matrix B. Any help or even ideas on this would be much appreciated.
Thanks
  1 Kommentar
Mathieu NOE
Mathieu NOE am 16 Okt. 2020
hello
this is a first level description of the problem, but we need to understand from a mathematical perspective how the elements of A and B are defined , not only the range but how each element is related to the others (random distribution ? )
what are the operation(s) you have to do on the A and B matrixes to compute your energie(s) ?
a kind of pseudo code would be helpful

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 16 Okt. 2020
You can form all combinations of two matrices using ndgrid,
A=rand(3), B=rand(3)
A = 3×3
0.2535 0.4016 0.2631 0.3204 0.5844 0.9297 0.6106 0.9268 0.6711
B = 3×3
0.7170 0.9237 0.3843 0.4447 0.0765 0.5473 0.0286 0.6168 0.3079
[AA,BB]=ndgrid(A,B)
AA = 9×9
0.2535 0.2535 0.2535 0.2535 0.2535 0.2535 0.2535 0.2535 0.2535 0.3204 0.3204 0.3204 0.3204 0.3204 0.3204 0.3204 0.3204 0.3204 0.6106 0.6106 0.6106 0.6106 0.6106 0.6106 0.6106 0.6106 0.6106 0.4016 0.4016 0.4016 0.4016 0.4016 0.4016 0.4016 0.4016 0.4016 0.5844 0.5844 0.5844 0.5844 0.5844 0.5844 0.5844 0.5844 0.5844 0.9268 0.9268 0.9268 0.9268 0.9268 0.9268 0.9268 0.9268 0.9268 0.2631 0.2631 0.2631 0.2631 0.2631 0.2631 0.2631 0.2631 0.2631 0.9297 0.9297 0.9297 0.9297 0.9297 0.9297 0.9297 0.9297 0.9297 0.6711 0.6711 0.6711 0.6711 0.6711 0.6711 0.6711 0.6711 0.6711
BB = 9×9
0.7170 0.4447 0.0286 0.9237 0.0765 0.6168 0.3843 0.5473 0.3079 0.7170 0.4447 0.0286 0.9237 0.0765 0.6168 0.3843 0.5473 0.3079 0.7170 0.4447 0.0286 0.9237 0.0765 0.6168 0.3843 0.5473 0.3079 0.7170 0.4447 0.0286 0.9237 0.0765 0.6168 0.3843 0.5473 0.3079 0.7170 0.4447 0.0286 0.9237 0.0765 0.6168 0.3843 0.5473 0.3079 0.7170 0.4447 0.0286 0.9237 0.0765 0.6168 0.3843 0.5473 0.3079 0.7170 0.4447 0.0286 0.9237 0.0765 0.6168 0.3843 0.5473 0.3079 0.7170 0.4447 0.0286 0.9237 0.0765 0.6168 0.3843 0.5473 0.3079 0.7170 0.4447 0.0286 0.9237 0.0765 0.6168 0.3843 0.5473 0.3079

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by