Start with this:lab_2_start.m Download lab_2_start.m and complete the unfinished lines. This pdf describes how to read data from a url:web-read.pdf Download web-read.pdf The url we will read data from...

1 answer below »

Start with this:lab_2_start.m

Download lab_2_start.m


and complete the unfinished lines.



This pdf describes how to read data from a url:web-read.pdf

Download web-read.pdf


The url we will read data from is :



https://celestrak.com/NORAD/elements/tle-new.txt(Links to an external site.)


Write a program that uses an input function to read an index number from the user, and prints the data for the selected satellite in the format used for assignment 1.


The program will read data into a variable namedsat_list, which will then be a vector of strings. Every 3 lines represents one satellite. You can read access a line of data as shown in the pdf:



sat_list(i)is line i from the data.


Satellite 1 will have it's name, TLE line 1 and TLE line 2 in



sat_list(1)



sat_list(2)



sat_list(3)


Satellite 2 will have it's name, TLE line 1 and TLE line 2 in



sat_list(4)



sat_list(5)



sat_list(6)


So if the number the user enters is saved in variablen, you need to compute the three index numbers fromn.


Store the three lines in string variables namedname, line_1andline_2, just like in assignment 1, but instead of using string literals, use thesat_list:



name = sat_list(1);


will put the name of satellite 1 into the name variable.


Here is an example program to illustrate the input function and using an index on a vector:indexing_1.m

Download indexing_1.m




% Illustrates using the input() function and % indexing a vector (list is a string vector, also refered to as % a list or array. list = ["first line" "second line" "third line" "fourth line" "fifth line"]; n = input("Enter an index number: "); line = list(n); fprintf("You entered: %d\nThis line is: %s\n", n, line); % Programming Assignment 2 % This is an outline for the program. The goal of the program is to read in % data for a collection of satellites, ask the user for a number, and print % the data for the selected satellite. Number 1 will mean the 1st satellite % in the liat, number 2 the 2nd satellite, etc. Because there are 3 lines % of data for each satellite, we need to compute from the number entered by % the user what line the specified satallites data begins on. Example: if % the user asks for satellite 3, we need to compute the line number as 7. % The name of satellite 3 will be on line 7, and the TLE orbital parameters % will be on lines 8 and 9. The orbital parameters we want to print are % obtained by extracting substrings from the TLE data lines and converting % them to numbers. % Read the data from the website. sat_list = string(splitlines(webread("https://celestrak.com/NORAD/elements/new.txt"))); % Each line below is not complete. Fill in the code to complete the line. % Ask the user what satellite they want and compute the line the data % for that satellite begins on. % We need to compute the index bercause each satellite takes three lines, sat_num = input( % get the number of the desired satallite sat_name_index = % compute the index from sat_num % get the lines with the name and TLE data from the list of data % that was read from the website and stored in sat_list. name = sat_list( % get the name line_1 = % this is on the next line after the name line_2 = % this is on the next line after line_1 % Get the required data from the strings line_1 and line_2 mean_motion = % extract substring and convert to number eccentricity = % extract substring and convert to number cat_num = % extract substring and convert to number fprintf( % print the extracted data
Answered Same DayOct 11, 2021

Answer To: Start with this:lab_2_start.m Download lab_2_start.m and complete the unfinished lines. This pdf...

Nishchay answered on Oct 11 2021
113 Votes
% Programming Assignment 2
% This is an outline for the program. The goal of the program is to read
in
% data for a collection of satellites, ask the user for a number, and print
% the data for the selected satellite. Number 1 will mean the 1st satellite
% in the liat, number 2 the 2nd satellite, etc. Because there are 3 lines
% of data for each satellite, we need to compute from the number entered by
% the user what line the specified satallites data begins on. Example: if
% the user asks for satellite 3, we need to compute the line number as 7.
% The name of satellite 3 will be on line 7, and the TLE orbital parameters
% will be on lines 8...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here