This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: 9/11/2008 1 Command Window Input and Output Friday September 12, 2008 User Input Input Statement Syntax: &gt;&gt; varname = input(Instructions to user); From wind power example: &gt;&gt; WindSpeed = input(Please enter the wind speed in m/s.) This prints the text in quotes to the command window and awaits user input The value that the user enters is now assigned to the variable name given in the input statement. Input Statement Options We can also have the user enter matrices: &gt;&gt; x = input(Enter the values for the matrix in brackets.) Use can now ente Use can now enter [1 2 3, 4 5 6] and now = 6 5 4 3 2 1 x And strings The user can also enter a string. &gt;&gt; x = input(Input your name.) will not work (it will only take the first value, as it reads the string as a sequence of scalars. The correct way to do this is: &gt;&gt; x = input(Input your name in quotes.) joe OR &gt;&gt; x = input(Input your name., s) tells matlab to expect a string as input 9/11/2008...
View Full Document
- Fall '05