{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HW03_soln - For students note how I divide the code into...

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

View Full Document Right Arrow Icon
note how I divide the code into sections: constants at top, input, calculations, and outputs. Does it not make the code more readable? Also note the outputs. This took me several iterations to get everything to line up. It might be easier to use spaces in the formats rather than tabs. Problem 1: % Constants g = 79000; % m/hr^2 M = 1000; % miles E = 4000; % miles % Inputs D = input('Enter Distance (miles): '); % Calculations Vmph = sqrt(2*g*E - 200*E^2/(81*(D+M+E)) + 2*g*E^2/(81*(D+M))); Vfps = Vmph*5280/3600; Vmps = Vfps/3.2808; % Outputs fprintf('\n'); % I like a blank line fprintf('Distance\t\t\t\tVelocity\n'); fprintf(' miles\t\tmiles/hour\tfeet/sec\tmeters/sec\n'); fprintf(' %.0f\t\t %.0f\t\t %.0f\t\t %.0f\n',D,Vmph,Vfps,Vmps); >> escape Enter Distance (miles): 240000 Distance Velocity miles miles/hour feet/sec meters/sec 240000 25142 36875 11240 >> escape Enter Distance (miles): 250000 Distance Velocity miles miles/hour feet/sec meters/sec 250000 25142 36875 11240
Background image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 2

HW03_soln - For students note how I divide the code into...

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

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