Elements Of Electromagnetics
7th Edition
ISBN: 9780190698614
Author: Sadiku, Matthew N. O.
Publisher: Oxford University Press
expand_more
expand_more
format_list_bulleted
Question
I am having trouble with the folloiwng MATLAB code. I am getting an error that says "unrecognized function or variable 'numericalPropogatorOptions". I have the aerospace toolbox and the aerospace blockset added. what add on do I have to download to use that function. How do I make this code work?
% Define Keplerian Elements
a = 29599.8; e = 0.0001; i = 0.9774; Omega = 1.3549; w = 0; M = 0.2645;
[RECI, VECI] = Kepler2RV(a, e, i, Omega, w, M);
initialState = [RECI * 1e3; VECI * 1e3]; % Initial position (m) and velocity (m/s)
% Define constants
mu = 3.986004418e14; % Gravitational constant (m^3/s^2)
earthRadius = 6378.1363 * 1e3; % Earth radius in meters
j2 = 1.08263e-3; % J2 perturbation coefficient
% Define propagator options
propOptions = numericalPropagatorOptions('CentralBody', 'Earth', ...
'GravitationalParameter', mu, ...
'InitialState', initialState, ...
'OutputTimeStep', 300); % Output every 300 seconds
% Add perturbations
addGravityModel(propOptions, 'Degree', 2, 'Order', 0); % J2 effect
addDragModel(propOptions, 'AtmosphereModel', 'Exponential', ...
'ReferenceArea', 1.0, 'DragCoefficient', 2.2, ...
'Mass', 500); % Atmospheric drag
addSolarRadiationPressureModel(propOptions, 'ReferenceArea', 1.0, ...
'Reflectivity', 1.3, 'Mass', 500); % SRP
addThirdBodyGravity(propOptions, 'Moon'); % Third-body effect from the Moon
addThirdBodyGravity(propOptions, 'Sun'); % Third-body effect from the Sun
% Propagate the orbit
endTime = 300 * 300; % 300 steps, each of 300 seconds
[t, state] = numericalPropagator(endTime, propOptions);
% Extract position and velocity for plotting
position = state(:, 1:3); % Position in ECI (meters)
velocity = state(:, 4:6); % Velocity in ECI (meters/second)
% Plot the orbit
plot3(position(:, 1), position(:, 2), position(:, 3));
xlabel('X (m)'); ylabel('Y (m)'); zlabel('Z (m)');
title('Simulated Orbit with Perturbations in ECI');
grid on;
function [RECI, VECI] = Kepler2RV(a, e, i, Omega, w, M)
mu = 398600.441799999971; % Earth's Standard Gravitational Parameter (GM)
Eps = 2.22044604925031e-8; % Machine epsilon
E = SolveKepler(M,e,Eps); % Eccentric Anomaly from Mean Anomaly
M = 2*atan(sqrt((1+e)/(1-e))*tan(E/2)); % True Anomaly obtained from Eccentric Anomaly
p = a*(1 - e^2); % Semiparameter (km)
% Position Coordinates in Perifocal Coordinate System
x = (p*cos(M)) / (1 + e*cos(M)); % x-coordinate (km)
y = (p*sin(M)) / (1 + e*cos(M)); % y-coordinate (km)
z = 0; % z-coordinate (km)
vx = -(mu/p)^(1/2) * sin(M); % velocity in x (km/s)
vy = (mu/p)^(1/2) * (e + cos(M)); % velocity in y (km/s)
vz = 0; % velocity in z (km/s)
% Transformation Matrix (3 Rotations)
t_rot = [cos(Omega)*cos(w)-sin(Omega)*sin(w)*cos(i) ...
(-1)*cos(Omega)*sin(w)-sin(Omega)*cos(w)*cos(i) ...
sin(Omega)*sin(i); ...
sin(Omega)*cos(w)+cos(Omega)*sin(w)*cos(i) ...
(-1)*sin(Omega)*sin(w)+cos(Omega)*cos(w)*cos(i) ...
(-1)*cos(Omega)*sin(i); ...
sin(w)*sin(i) cos(w)*sin(i) cos(i)];
% Transformation Perifocal xyz to ECI
RECI = t_rot*[x y z]';
VECI = t_rot*[vx vy vz]';
end
function E = SolveKepler(M,e,Eps)
% Iterative Solution of Kepler's equation (M = E-e*sin(E))
%==========================================================================
% Inputs: M = Mean Anomaly (rad)
% e = Eccentricity
% Eps = Machine epsilon
% Output: E = Eccentric Anomaly (rad)
%==========================================================================
E0 = M;
E1 = E0 - (E0 - e*sin(E0) - M)/(1 -e*cos(E0));
while (abs(E1-E0) > Eps)
E0 = E1;
E1 = E0 - (E0 - e*sin(E0) - M)/(1 - e*cos(E0));
end
E = E1;
end
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps
Knowledge Booster
Similar questions
- please write a matlab codearrow_forwardHow do I input this code for this MATLAB problem? Thanks!arrow_forwardI want to run the SGP4 propagator for the ISS (ID = 25544) I got from spacetrack.org in MATLAB. I don't know where to get the inputs of the function. Where do I get the inFile and outFile that is mentioned in the following function. % Purpose: % This program shows how a Matlab program can call the Astrodynamic Standard libraries to propagate % satellites to the requested time using SGP4 method. % % The program reads in user's input and output files. The program generates an % ephemeris of position and velocity for each satellite read in. In addition, the program % also generates other sets of orbital elements such as osculating Keplerian elements, % mean Keplerian elements, latitude/longitude/height/pos, and nodal period/apogee/perigee/pos. % Totally, the program prints results to five different output files. % % % Usage: Sgp4Prop(inFile, outFile) % inFile : File contains TLEs and 6P-Card (which controls start, stop times and step size) % outFile : Base name for five output files %…arrow_forward
- HW Matlab 1) Create a variable ftemp to store a temperature in degrees Fahrenheit (F). Write m-file to convert this to degrees Celsius and store the result in a variable ctemp. The conversion factor is C = (F —32) * 5/9. 2) Write m-file to generate a matrix of random integers of size 100 by 100 their values between 15 to 80. 3) Free fall of objects is given by y =5mgt? where a is the acceleration, v is the velocity, y is the distance, m is the mass of the object, g is the gravitational acceleration. Plot the distance and velocity of the object for 15 seconds after its fall from rest (y = 0). Take m = 0.2 kg.arrow_forwardPlease help, this for Matlab the image is the first question with following 2 and 3 they go together. 2. Solving the question by using bisection.m with the stopping criterion at 1%. Report the root and # of iterations. 3. by using newton-Raphson matlab script with the stopping criterion at 0.1%. Report the root and # of iterations.arrow_forwardPlease follow the instructions and the requirements according to the pictures above and I kinda need the solution quickly. The language of the code is in Matlab, thank you in advance.arrow_forward
- Could you please fix my code it’s supposed to look like the graph that’s on the picture. But the lines do not cross eachother at the beginning. Could you make the lines look like the lines on the graph? Use this code in MATLAB and fix it. % Sample data for Diesel and Petrol cars carPosition = linspace(1, 60, 50); % Assumed positions of cars % Define your seed here seed = 50; rand('seed',seed); % Set the seed for reproducibility % Assumed CO2 emissions for Diesel and Petrol CO2Diesel = 25 + 5*cos(carPosition/60*2*pi) + randn(1, 50)*5; % Random data for Diesel CO2Petrol = 20 + 5*sin(carPosition/60*2*pi) + randn(1, 50)*5; % Random data for Petrol % Fit polynomial curves with a reduced degree of 2 pDiesel = polyfit(carPosition, CO2Diesel, 2); pPetrol = polyfit(carPosition, CO2Petrol, 2); % Generate points for best fit lines fitDiesel = polyval(pDiesel, carPosition); fitPetrol = polyval(pPetrol, carPosition); % Plotting the data figure; hold on; % Plot Diesel best fit line…arrow_forwardUSE MATLAB AND SOLVE THIS QUESTION The ideal gas law relates the pressure P, volume V, absolute temperature T, and amount of gas n. The law is P = nRT/ V where R is the gas constant. An engineer must design a large natural gas storage tank to be expandable to maintain the pressure constant at 2.2 atm. In December when the temperature is 4°F (- 15°C), the volume of gas in the tank is 28 500 ft3 . What will the volume of the same quantity of gas be in July when the temperature is 88°F (31°C)? (Hint: Use the fact that n, R, and P are constant in this problem. Note also that K =°C +273.2.)arrow_forwardThis code keeps on generating graphs with different curves. The picture that you see two different graphs comes from the same code but both of them have different curves. I need the curve to look like the picture that only has one graph. I basically need the line to have a slight curve and every time I run the code it will come up as the same graph every time. Use this code on MATLAB and fix it % Sample data for Diesel and Petrol cars carPosition = linspace(1, 60, 50); % Assumed positions of cars % Use the 'seed' function instead of 'rng' seed = 50; % Define your seed here rand('seed',seed); % Assumed CO2 emissions for Diesel and Petrol CO2Diesel = 25 + 5*cos(carPosition/60*2*pi) + randn(1, 50)*5; % Random data for Diesel CO2Petrol = 20 + 5*sin(carPosition/60*2*pi) + randn(1, 50)*5; % Random data for Petrol % Fit polynomial curves with a reduced degree of 2 pDiesel = polyfit(carPosition, CO2Diesel, 2); pPetrol = polyfit(carPosition, CO2Petrol, 2); % Generate points for best fit…arrow_forward
- Use MATLAB please make code for this.arrow_forwardI need help in the following MATLAB code. How do I add the code to answer the following question "Do you find more object detections in the image than the one that is cropped out? Explain how you would discriminate that from a dead pixel, a hot pixel, or a cosmic ray event." fname = '00095337.fit'; fInfo = fitsinfo(fname); img = fitsread(fname); % Crop the image to show just the object: img_cropped = img(1980:2030,1720:1780); % Load the labeled image img_labeled = imread('00095337_labeled_stars.png'); img_labeled = img_labeled(102:863,605:1363,:); % Get rid of "hot" pixels (cosmic rays, disfunctional pixels) max_acceptable_value = 1300; img(img>max_acceptable_value) = max_acceptable_value; % Plot the images f1 = figure(); tgroup1 = uitabgroup('Parent',f1); tab(1) = uitab('Parent', tgroup1, 'Title', 'Raw image'); ax(1) = axes('parent',tab(1)); imagesc(img) axis equal axis([0,size(img,2),0,size(img,1)]+0.5) colormap(gray(256)); xlabel('x [px]') ylabel('y [px]')…arrow_forwardMATLAB..Hand written plz asap....i'll upvote surearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Elements Of ElectromagneticsMechanical EngineeringISBN:9780190698614Author:Sadiku, Matthew N. O.Publisher:Oxford University PressMechanics of Materials (10th Edition)Mechanical EngineeringISBN:9780134319650Author:Russell C. HibbelerPublisher:PEARSONThermodynamics: An Engineering ApproachMechanical EngineeringISBN:9781259822674Author:Yunus A. Cengel Dr., Michael A. BolesPublisher:McGraw-Hill Education
- Control Systems EngineeringMechanical EngineeringISBN:9781118170519Author:Norman S. NisePublisher:WILEYMechanics of Materials (MindTap Course List)Mechanical EngineeringISBN:9781337093347Author:Barry J. Goodno, James M. GerePublisher:Cengage LearningEngineering Mechanics: StaticsMechanical EngineeringISBN:9781118807330Author:James L. Meriam, L. G. Kraige, J. N. BoltonPublisher:WILEY
Elements Of Electromagnetics
Mechanical Engineering
ISBN:9780190698614
Author:Sadiku, Matthew N. O.
Publisher:Oxford University Press
Mechanics of Materials (10th Edition)
Mechanical Engineering
ISBN:9780134319650
Author:Russell C. Hibbeler
Publisher:PEARSON
Thermodynamics: An Engineering Approach
Mechanical Engineering
ISBN:9781259822674
Author:Yunus A. Cengel Dr., Michael A. Boles
Publisher:McGraw-Hill Education
Control Systems Engineering
Mechanical Engineering
ISBN:9781118170519
Author:Norman S. Nise
Publisher:WILEY
Mechanics of Materials (MindTap Course List)
Mechanical Engineering
ISBN:9781337093347
Author:Barry J. Goodno, James M. Gere
Publisher:Cengage Learning
Engineering Mechanics: Statics
Mechanical Engineering
ISBN:9781118807330
Author:James L. Meriam, L. G. Kraige, J. N. Bolton
Publisher:WILEY