Lecture 8

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

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

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

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

View Full Document
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

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

View Full Document
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]’)
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

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

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

This note was uploaded on 09/05/2011 for the course EGM 3344 taught by Professor Raphaelhaftka during the Fall '09 term at University of Florida.

Page1 / 24

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

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

View Full Document
Ask a homework question - tutors are online