Multiply each element of a matrix by different element from another matrix

1 view (last 30 days)
I am trying to fix the for loop, so I can find Fsp for each angle, but xi is not the same dimension as Fsp. Xi is based on an angle theta, 0-360. Fsp is a function of Xi, Fspo, and Giss.
massg=10^-5:10; %mass [g]
mass=massg/1000; %mass [kg]
Ra_leo=2000; Ra_geo=35786; % altitude[km]
R=6378; %Radius of Earth [km]
riss=450+R; %ISS altitude [km]
rgps=20200+R;%GPS altitude [km]
rgeo=35786+R;%GEO altitude [km]
theta=0:360; %angle [degrees]
xi=cosd(theta); %shielding factor
%Graviational focusing factor
Giss=1+Ra_leo/riss;
Ggps=1+Ra_leo/rgps;
Ggeo=1+Ra_geo/rgeo;
% Calculate Forces
F1=(2.2E3.*mass.^.306+15).^-4.38;
F2=1.3E-19.*(mass+10.*mass.^11.*mass.^2+10.*mass.^27.*mass.^4).^-0.36;
F3=1.3E-16.*(mass+10^6.*mass.^2).^-0.85;
Fspo=3.15576E7.*(F1+F2+F3);
for i=1:length(Fspo)
for j=1:length(theta)
Fsp(j)=Fspo.*xi.*Giss;
end
end
  3 Comments
Stephen23
Stephen23 on 28 Jul 2021
"It's stated in the hw problem as using that"
They are extremely odd values to use. One should definitely not assume that academics do not make mistakes.
massg = 10.^(-5:1)
massg = 1×7
0.0000 0.0001 0.0010 0.0100 0.1000 1.0000 10.0000

Sign in to comment.

Answers (1)

David Hill
David Hill on 27 Jul 2021
massg=10^-5:10; %mass [g]
mass=massg/1000; %mass [kg]
Ra_leo=2000; Ra_geo=35786; % altitude[km]
R=6378; %Radius of Earth [km]
riss=450+R; %ISS altitude [km]
rgps=20200+R;%GPS altitude [km]
rgeo=35786+R;%GEO altitude [km]
theta=0:360; %angle [degrees]
xi=cosd(theta); %shielding factor
%Graviational focusing factor
Giss=1+Ra_leo/riss;
Ggps=1+Ra_leo/rgps;
Ggeo=1+Ra_geo/rgeo;
% Calculate Forces
F1=(2.2E3.*mass.^.306+15).^-4.38;
F2=1.3E-19.*(mass+10.*mass.^11.*mass.^2+10.*mass.^27.*mass.^4).^-0.36;
F3=1.3E-16.*(mass+10^6.*mass.^2).^-0.85;
Fspo=3.15576E7.*(F1+F2+F3);
%try meshgrid
[Fspo,xi]=meshgird(Fspo,xi);
Fsp=Fspo.*xi*Giss;%matrix with all the calculations

Categories

Find more on Gravitation, Cosmology & Astrophysics in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!