This preview shows page 1. Sign up to view the full content.
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
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
Add code so the program will
ask the user to input the
Cost Per Gallon
Miles Per Gallon
Distance of Trip
CPG = input('Enter the cost per gallon of gas in $: ');
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.
- Spring '06