Week6_Workshop_Full-1

2f output a numerical value with two places after the

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: a, u, b, u) Result: %6.2f output a numerical value with two places after the decimal, 3 places before plus a sign. %s output a text value Alpha = 34.12 inches and Beta = 56.123 inches Notes: the value stored in the variable u is the character Engineering string ‘inches’. Education Output Syntax General Form: %m.nf ‘m’ is the ‘field width’ and should include space for the decimal, a leading sign (+ or -) and the ‘n’ digits to the right of the decimal pt. If ‘m’ is too small, MATLAB automatically increases it. ‘n’ us the number of digits displayed to the right of the decimal pt. e.g.: %4.0f would yield a decimal display Enter the following lines of code in the command window and run: fprintf(‘\n pi = %10.2f and pi^2= %2.0f \n’, pi, pi^2) fprintf(‘\n pi/2 = %0.6f and pi^pi= %14.8f\n’, pi, pi^2) fprintf(‘\n exp(0) = %0.6f and that = %f\n’, 1, 2, sind(45), 0) Engineering Education Trip Program Comment out the assignment (initialization) statements Add code so the program will ask the user to input the following: Cost Per Gallon Miles Per Gallon Distance of Trip Budget CPG = input('Enter the cost per gallon of gas in $: '); Afte...
View Full Document

This note was uploaded on 01/28/2014 for the course ENGE 1114 taught by Professor Twknott during the Spring '06 term at Virginia Tech.

Ask a homework question - tutors are online