question archive Using Matlab how do you code this without using loops
Subject:MathPrice: Bought3
Using Matlab how do you code this without using loops.
You are going to find all the "potentially habitable exoplanets". An exoplanet is habitable when all of these conditions are true:
You should locate and save the positions that satisfy the above criteria (save to variable name ind_habitable). Then, save the names of the exoplanets associated with those index locations to the variable 'habitable_exoplanets'. Use this variable exactly, as it will be checked in the tests below. Print the results to the screen exactly like this (don't have any typos):
These exoplanets are within the habitable zone:
"Kepler-22"
"Kepler-452"
"Kepler-62"
SOURCE: definition of habitable is loosely based on http://phl.upr.edu/projects/habitable-exoplanets-catalog/methods
Step 3: Remove NaNs and Sort by size
You are going to sort the planets by size in order of largest to smallest.
a. Remove NaNs - you will notice that some values in the rad array are filled with NaN instead of a value. This is because some exoplanets do not have data for their radius. The first step of this part is to remove all the data (rad and names_pl) that does not have available radius data. Save indices of where the NaNs are located to the variable named remove.
b. Sort the planets by size - The final step of this part is to sort the planets by their size from largest to smallest. You must sort only the data without the NaNs in it, so make sure to remove them first. Then you will use the built in function sort to sort from largest to smallest (save the sorted radii to array with variable name rad_sort). Save the indices of the sort to the array with variable name ind_sort. Save the names in sorted order to the variable name names_pl_sorted. Once you have sorted, print out the top five planets exactly like this (don't have any typos):
Top five largest exoplanets:
"HD 100546"
"GQ Lup"
"CT Cha"
"WASP-79"
"Kepler-435"