
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
- How do I input this code for this MATLAB problem? Thanks!arrow_forwardHW 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_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_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_forwardI need help with a MATLAB code. I am trying to solve this question. Based on the Mars powered landing scenariosolve Eq. (14) via convex programming. Report the consumed fuel, and discuss the results with relevant plots. I am using the following MATLAB code and getting an error. I tried to fix the error and I get another one saying something about log and exp not being convex. Can you help fix my code and make sure it works. The error is CVX Warning: Models involving "log" or other functions in the log, exp, and entropy family are solved using an experimental successive approximation method. This method is slower and less reliable than the method CVX employs for other models. Please see the section of the user's guide entitled The successive approximation method for more details about the approach, and for instructions on how to suppress this warning message in the future.Error using .* (line 173)Disciplined convex programming error: Cannot perform the operation:…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_forwardI need help with my MATLAB code. I am trying to plot the semi major axis and eccentricity with the following code with rungge kutta method. I have two different nnn's in the code which produce two different step sizes. So, I am wondering why both give the same exact plots for semi-major axis and eccentricity. The orbital dynamics fucntion considers J2, drag, SRP, and third body effects. % Orbital elements obtained from TLE inc = 63.5000118; % Inclination (degs) raan = 19.999977; % RAAN (degs) ecc = 0.001; % Eccentricity argp = 120.02165342; % argument of perigee (degs) v = 0; % True anomaly (degs) a = 6584.697271; % Semi-major axis (km) mu = 3.986e5; period = (2*pi*sqrt((a^3)/mu)); % Calculating the state vector in eci frame [x, y, z, vx, vy, vz] = kep2cart(a, ecc, inc, raan, argp, v); Y = [x, y, z, vx, vy, vz]; options = odeset('RelTol', 1e-12, 'AbsTol', 1e-12); nnn1 = 800; t_step1 = period/nnn1; m6 = 50; h_step6 = t_step1/m6; t_total6 = 0:h_step6:10*period; [t6,…arrow_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