HW9_ruzmora

HW9_ruzmora - disp(' Time[sec] Height') fprintf('%10.0f...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 %Chapter 5 Problem 1 %This program calculates the distance to the horizon in Mars and the Earth clear all clc %Set all variables R=[20924640 h=[0:1000:10000] [r_new,h_new]=meshgrid(R,h) d=sqrt(2*r_new.*h_new+h_new.^2)/5280 table=[h',d(:,1),d(:,2)] disp('Distance to the Horizon as you climb a mountain') disp('Height[feet] Earth[mi] Mars[mi]') fprintf('%10.0f %10.0f %10.0f\n',table') function height_rocket=height(t) %This function calculates the height of a rocket height_rocket=2.13*t.^2-0.0013*t.^4+0.000034*t.^4.751 %Chapter 5 Problem 5 b %This program calculates and plots the height of a rocket clear all clc t=0:2:200 rocket_h=height(t) if (rocket_h<=0) loc=find(rocket_h>=0) height_new=[rocket_h(loc) rocket_h(max(loc)+1)] time_new=[t(loc) t(max(loc)+1)] plot(time_new,height_new) xlabel('Time[sec]') ylabel('Height') else loc=find(t<=100) height_new=rocket_h(loc) time_new=t(loc) table=[time_new',height_new'] disp('Height reached by the rocket')
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: disp(' Time[sec] Height') fprintf('%10.0f %10.3f\n',table') plot(time_new,height_new) xlabel('Time[sec]') ylabel('Height') Sheet1 Page 2 title('Rocket height for 1st 100 seconds') end %Chapter 5 Problem 5 c %This program calculates the height of a rocket clc clear all t=0:2:200 h_1=height(t) loc2=find(h_1&lt;0) fall_h=h_1(loc2) time_new=t(loc2) disp('This is the time in seconds when the rocket begins to fall.') fall_t=min(time_new)%Find the minimum negative value of height and find the time [min_h loc] = min(h_1) disp('This is the time in seconds when the rocket hits the ground.') min_t=t(loc) Sheet1 Page 3 11132880] %Radius of Earth and Mars in feet %height of the hills %making Earth's and Mars' radius same as height %Calculating distance %Generate a table Sheet1 Page 4 %Find the negative values of height %find the minimum height and then find the time...
View Full Document

This note was uploaded on 05/21/2010 for the course EEL 2161 taught by Professor Lopez during the Spring '10 term at FAU.

Page1 / 4

HW9_ruzmora - disp(' Time[sec] Height') fprintf('%10.0f...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online