Lecture 8 - fprintf( ) of Matrices Score = [1 2 3 4; 95 88...

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

View Full Document Right Arrow Icon
fprintf( ) of Matrices Score = [1 2 3 4; 95 88 102 93; 89 84 95 85]; Game 1 score: UF: 95 FSU: 89 Game 2 score: UF: 88 FSU: 84 Game 3 score: UF: 102 FSU: 95 Game 4 score: UF: 93 FSU: 85 fprintf(‘Game % 1.0f score: UF: % 3.0f FSU: % 3.0f \n’,Score) fprintf control codes \n Start new line \t Tab
Background image of page 1

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

View Full DocumentRight Arrow Icon
Interactive input Function The input function allows you to prompt the user for values directly from the command window Enter either “value” or “stream” n = input(‘ promptstring ’) function [name, sid, phone, email] = register name = input( 'Enter your name: ' , 's' ); sid = input( 'Enter your student ID: ' ); phone = input( 'Enter your Telphone number: ' , 's' ); email = input( 'Enter your Email address: ' , 's' ); string value
Background image of page 2
Interactive input Function >> [name,sid,phone,email] = register Enter your name: Alice Gator Enter your student ID: 12345678 Enter your Telphone number: 666-8888 Enter your Email address: Alicegator@ufl.edu name = Alice Gator sid = 12345678 phone = 666-8888 email = Alicegator@ufl.edu
Background image of page 3

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

View Full DocumentRight Arrow Icon
Interactive M-File An interactive M-file for free-falling bungee jumper Use input and disp functions for input/output function freefallinteract % freefallinteract() % compute the free-fall velocity of a bungee jumper % input: interactive from command window % output: ve;ocity = downward velocity (m/s) g=9.81; % acceleration of gravity m = input( 'Mass (kg): ' ); cd = input( 'Drag coefficient (kg/m): ' ); t = input( 'Time (s): ' ); disp( ' ' ) disp( 'Velocity (m/s):' ) vel = sqrt(g*m/cd)*tanh(sqrt(g*cd/m)*t); disp([t;vel]’)
Background image of page 4
Interactive M-File- result >> freefallinteract Mass (kg): 68.1 Drag coefficient (kg/m): 0.25 Time (s): 0:1:20 Velocity (m/s): 0 0 1.0000 9.6939 2.0000 18.7292 3.0000 26.6148 4.0000 33.1118 5.0000 38.2154 6.0000 42.0762 7.0000 44.9145 8.0000
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 24

Lecture 8 - fprintf( ) of Matrices Score = [1 2 3 4; 95 88...

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

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