loop structure variables in formula
Mostra commenti meno recenti
I need help i have the following formula which runs as a function : f=G*(Mass1*Mass2)/((Distance1 - Distance2)^2) %<< this formula compares gravitational force between 2 planets.
G, Mass 1 and Distance 1 have already been defined in the script via user input (select planet name) these values are constant.
I need to extract Mass2 and Distance 2.
the following structure is where my data is extracted.

I need the formula to loop and keep changing Mass2 and Distance 2 so that it presents all the possibilities as 1 list. e.g
Note: venus has been selected as a user input which pre-defined Mass 1 and Distance1. So it cannot be presented in the list.
‘Sun’ [5.52599e+22] %< These values are not correct, just represents the formula result
‘Mercury’ [4.40086e+16]
‘Earth’ [1.10589e+18]
‘Mars’ [1.45682e+16]
‘Jupiter’ [1.37411e+18]
‘Saturn’ [1.06038e+17]
‘Uranus’ [3.71529e+15]
‘Neptune’ [1.72081e+15]
‘Pluto’ [1.20524e+11]
‘Mercury’ [4.40086e+16]
I need help making the loop and list work. If you can provide the code for this it would be much appreciated. Thanks
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Live Scripts and Functions in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!