SlideShare a Scribd company logo
1 of 1
% Homework #2, Problem #2, Physics 262
%Define parameters
par.rhoc0 = 4.46e3; % present critical density
par.rhom0 = 0.28 * par.rhoc0; % present mass density
par.rhor0 = 0.260; % present radiation density
par.rhoL0 = 0.72 * par.rhoc0; % present cosmological constant density
% Plotting rho(a) (problem 2.2)
% note that the various rho_i functions are defined in rhe rhom.m, rhor.m, and
% rhol.m files (attached)
a = logspace(-6,0); % creates "a" values for the x axis
y1=rhor(a,par);
y2=rhom(a,par);
y3=rhol(a,par);
loglog(a,y1,'k-');
hold on
loglog(a,y2,'k:');
loglog(a,y3,'k-.');
hold off
%plot values
xlabel('log(a)')
ylabel('log(rho )')
title('Log-Log Plot for Problem #2 of Hw #2 in Phys 262')
legend('rho_r','rho_m','rho_{Lambda}')
% rhol.m
function y = rhol(a,par)
y = par.rhoL0*a.^(0)
% rhom.m
function y = rhom(a,par)
y = par.rhom0*a.^(-3)
% rhor.m
function y = rhor(a,par)
y = par.rhor0*a.^(-4)

More Related Content

More from Mark Yashar

Mark_Yashar_Resume_2017
Mark_Yashar_Resume_2017Mark_Yashar_Resume_2017
Mark_Yashar_Resume_2017Mark Yashar
 
MYashar_Computing_Skills_2017
MYashar_Computing_Skills_2017MYashar_Computing_Skills_2017
MYashar_Computing_Skills_2017Mark Yashar
 
MYashar_SFSU_Reserch_Tech1_Windows
MYashar_SFSU_Reserch_Tech1_WindowsMYashar_SFSU_Reserch_Tech1_Windows
MYashar_SFSU_Reserch_Tech1_WindowsMark Yashar
 
Mark_Yashar_Resume_Fall_2016
Mark_Yashar_Resume_Fall_2016Mark_Yashar_Resume_Fall_2016
Mark_Yashar_Resume_Fall_2016Mark Yashar
 
Myashar_Resume_2016
Myashar_Resume_2016Myashar_Resume_2016
Myashar_Resume_2016Mark Yashar
 
YQL_Batch_Queries_Notes_Examples
YQL_Batch_Queries_Notes_ExamplesYQL_Batch_Queries_Notes_Examples
YQL_Batch_Queries_Notes_ExamplesMark Yashar
 
Elevator_Pitch_Intros_Objectives
Elevator_Pitch_Intros_ObjectivesElevator_Pitch_Intros_Objectives
Elevator_Pitch_Intros_ObjectivesMark Yashar
 
MYashar_CoverLetter_Long_2016
MYashar_CoverLetter_Long_2016MYashar_CoverLetter_Long_2016
MYashar_CoverLetter_Long_2016Mark Yashar
 
myashar_research_2016
myashar_research_2016myashar_research_2016
myashar_research_2016Mark Yashar
 
microquasar_slides_web1
microquasar_slides_web1microquasar_slides_web1
microquasar_slides_web1Mark Yashar
 
Company_X_Data_Analyst_Challenge
Company_X_Data_Analyst_ChallengeCompany_X_Data_Analyst_Challenge
Company_X_Data_Analyst_ChallengeMark Yashar
 
MYashar_Cover_Update_2015
MYashar_Cover_Update_2015MYashar_Cover_Update_2015
MYashar_Cover_Update_2015Mark Yashar
 
MYashar_LLNL_ESGF_UV-CDAT
MYashar_LLNL_ESGF_UV-CDATMYashar_LLNL_ESGF_UV-CDAT
MYashar_LLNL_ESGF_UV-CDATMark Yashar
 
MYashar_UCB_BIDS
MYashar_UCB_BIDSMYashar_UCB_BIDS
MYashar_UCB_BIDSMark Yashar
 
nested_polygons_angelo_coast.kml
nested_polygons_angelo_coast.kmlnested_polygons_angelo_coast.kml
nested_polygons_angelo_coast.kmlMark Yashar
 

More from Mark Yashar (17)

Mark_Yashar_Resume_2017
Mark_Yashar_Resume_2017Mark_Yashar_Resume_2017
Mark_Yashar_Resume_2017
 
MYashar_Computing_Skills_2017
MYashar_Computing_Skills_2017MYashar_Computing_Skills_2017
MYashar_Computing_Skills_2017
 
MYashar_SFSU_Reserch_Tech1_Windows
MYashar_SFSU_Reserch_Tech1_WindowsMYashar_SFSU_Reserch_Tech1_Windows
MYashar_SFSU_Reserch_Tech1_Windows
 
Mark_Yashar_Resume_Fall_2016
Mark_Yashar_Resume_Fall_2016Mark_Yashar_Resume_Fall_2016
Mark_Yashar_Resume_Fall_2016
 
Myashar_Resume_2016
Myashar_Resume_2016Myashar_Resume_2016
Myashar_Resume_2016
 
YQL_Batch_Queries_Notes_Examples
YQL_Batch_Queries_Notes_ExamplesYQL_Batch_Queries_Notes_Examples
YQL_Batch_Queries_Notes_Examples
 
Elevator_Pitch_Intros_Objectives
Elevator_Pitch_Intros_ObjectivesElevator_Pitch_Intros_Objectives
Elevator_Pitch_Intros_Objectives
 
MYashar_CoverLetter_Long_2016
MYashar_CoverLetter_Long_2016MYashar_CoverLetter_Long_2016
MYashar_CoverLetter_Long_2016
 
myashar_research_2016
myashar_research_2016myashar_research_2016
myashar_research_2016
 
thesis_mark5
thesis_mark5thesis_mark5
thesis_mark5
 
microquasar_slides_web1
microquasar_slides_web1microquasar_slides_web1
microquasar_slides_web1
 
hw2_prob2
hw2_prob2hw2_prob2
hw2_prob2
 
Company_X_Data_Analyst_Challenge
Company_X_Data_Analyst_ChallengeCompany_X_Data_Analyst_Challenge
Company_X_Data_Analyst_Challenge
 
MYashar_Cover_Update_2015
MYashar_Cover_Update_2015MYashar_Cover_Update_2015
MYashar_Cover_Update_2015
 
MYashar_LLNL_ESGF_UV-CDAT
MYashar_LLNL_ESGF_UV-CDATMYashar_LLNL_ESGF_UV-CDAT
MYashar_LLNL_ESGF_UV-CDAT
 
MYashar_UCB_BIDS
MYashar_UCB_BIDSMYashar_UCB_BIDS
MYashar_UCB_BIDS
 
nested_polygons_angelo_coast.kml
nested_polygons_angelo_coast.kmlnested_polygons_angelo_coast.kml
nested_polygons_angelo_coast.kml
 

hw2problem2.m

  • 1. % Homework #2, Problem #2, Physics 262 %Define parameters par.rhoc0 = 4.46e3; % present critical density par.rhom0 = 0.28 * par.rhoc0; % present mass density par.rhor0 = 0.260; % present radiation density par.rhoL0 = 0.72 * par.rhoc0; % present cosmological constant density % Plotting rho(a) (problem 2.2) % note that the various rho_i functions are defined in rhe rhom.m, rhor.m, and % rhol.m files (attached) a = logspace(-6,0); % creates "a" values for the x axis y1=rhor(a,par); y2=rhom(a,par); y3=rhol(a,par); loglog(a,y1,'k-'); hold on loglog(a,y2,'k:'); loglog(a,y3,'k-.'); hold off %plot values xlabel('log(a)') ylabel('log(rho )') title('Log-Log Plot for Problem #2 of Hw #2 in Phys 262') legend('rho_r','rho_m','rho_{Lambda}') % rhol.m function y = rhol(a,par) y = par.rhoL0*a.^(0) % rhom.m function y = rhom(a,par) y = par.rhom0*a.^(-3) % rhor.m function y = rhor(a,par) y = par.rhor0*a.^(-4)