Question

In: Computer Science

Write a .m function file on MATLAB that reads the parameters stored in the file missile...

Write a .m function file on MATLAB that reads the parameters stored in the file missile data.txt into MATLAB. The function should have the following declaration: function [X0, Y0, Z0, m0, mf, Thmag0, theta, phi, Tburn] = read input( input filename, M id) where input filename is a string variable denoting the name of the file to be read and M_id is an integer which denotes the missile ID. The outputs are the initial position (X0, Y0, Z0), initial and landing mass (m0, mf), initial thrust magnitude (Thmag0), aunch angles (theta and phi) and burn time (T burn). When the input M_id is not available in the file, the function should set all outputs to NaN and display an error warning message to screen. Use "importdata" or "textscan" function to read the parameters.

The text file is:

# Missile parameters in the following order from left to right:
# Missile ID
# Initial position in X0, Y0, Z0 coordinate (m)
# Initial mass and landing mass: m0 and mf (kg)
# Initial thrust magnitude Thmag0 (N) 
# Direction angle (degree): theta, phi
# Burn time Tburn (s)   
1       0.12    29999.14        1.54    700     90      100000.00       -41.24  52.01   11.11
2       0.15        0.54        2.54    700     90      101000.00        32.65  53.02   11.05
3       0.10      101.43        2.43    700     90       99000.00        20.18  53.62   11.09
4       0.16    29812.45        2.12    700     90       96000.00       -15.65  50.51   11.13
5       0.11    15432.98        0.15    700     90       90000.00         5.86  49.07   11.02
6       0.14    29934.54        2.24    700     90       85000.00       -25.34  51.52   11.05
7       0.13      212.43        1.23    700     90       80000.00        10.24  50.05   11.98
        

Solutions

Expert Solution


Related Solutions

Write a parameterized function that takes in a file name as a parameter, reads the file,...
Write a parameterized function that takes in a file name as a parameter, reads the file, calculates the factorial of each number, and displays a formatted output as follows: Factorial of 10 = 3628800 Factorial of 5 = 120
show the MATLAB Code with comments and Write an .m file in MATLAB, that records audio...
show the MATLAB Code with comments and Write an .m file in MATLAB, that records audio (you can record your own voice for 20 seconds), takes Fourier transform of the signal (probably FFT).
BY Using MATLAB software: Exercise 3: Calculation of the parameters of a dipole. % M-File: ML0804...
BY Using MATLAB software: Exercise 3: Calculation of the parameters of a dipole. % M-File: ML0804 % % Perform numerical integration to find % beam solid angle, directivity, and the % maximum power function for a given length % dipole. % % Variables % L dipole length (in wavelengths) % bL2 phase constant * length/2 % N number of theta points % th,thr angle theta in degrees,radians % dth differential theta % num,den temporary variables % F un-normalized power function...
write a Matlab function file to solve system Ax=b by using the output of the function...
write a Matlab function file to solve system Ax=b by using the output of the function lufac2a your function should have inputs f=matrix return from lufac2a, piv=array return by lufac2a and b=right hand side of your system.the only output for your system should be x guideline 1.use the column access for the matrix entries 2. do not create any other matrix in your function-get your data directly from the matrix passed into your function 3.do not use Matlab command designed...
Write a simple text-formating.cpp file that reads (asks for then reads) a text file and produces...
Write a simple text-formating.cpp file that reads (asks for then reads) a text file and produces another text file in Which blank lines are removed, multiple blanks are replaced with a single blank, and no lines are longer than some given length (let say 80). Put as many words as possible on the same line (as close as possible to 80 characters). You will have to break some lines of the given file, but do not break any words or...
C++ Write a program that prompts for a file name and then reads the file to...
C++ Write a program that prompts for a file name and then reads the file to check for balanced curly braces, {; parentheses, (); and square brackets, []. Use a stack to store the most recent unmatched left symbol. The program should ignore any character that is not a parenthesis, curly brace, or square bracket. Note that proper nesting is required. For instance, [a(b]c) is invalid. Display the line number the error occurred on. These are a few of the...
Using Python 3 Write a function reads the file called simpleinterest.txt. Each row in simpleinterest.txt is...
Using Python 3 Write a function reads the file called simpleinterest.txt. Each row in simpleinterest.txt is a comma seperated list of values in the order of PV, FV, n, r. For each row, there is one value missing. Write an output file that fills in the missing value for each row.
Write a Matlab script-file probl1.m to execute the requested commands (as much as possible) in the...
Write a Matlab script-file probl1.m to execute the requested commands (as much as possible) in the exercises below. Increase N a number of times according to N = 4, 8, 16, 32, 64, 128, . . . (1) Determine for each N the (exact) error. (2) Determine for N ≥ 16 also the convergence ratio q(h/2). This script should be based on a function-file trap.m (trapezoidal integration) as follows: function [totarea] = trap(N) format long; a = 0; b =...
Write a program that reads a file (provided as attachment to this assignment) and write the...
Write a program that reads a file (provided as attachment to this assignment) and write the file to a different file with line numbers inserted at the beginning of each line. Such as Example File Input: This is a test Example File Output 1. This is a test. (Please comment and document your code and take your time no rush).
Write a program that reads a file line by line, and reads each line’s tokens to...
Write a program that reads a file line by line, and reads each line’s tokens to create a Student object that gets inserted into an ArrayList that holds Student objects.  Each line from the file to read will contain two strings for first and last name, and three floats for three test grades.  After reading the file and filling the ArrayList with Student objects, sort the ArrayList and output the contents of the ArrayList so that the students with the highest average...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT