From: mohamed saber on 16 Jul 2010 02:03 hello.....i'm a beginner in matlab........and i have a question if i want to insert an (input)....its form is ex: r=input('enter your password','s') what is the mean of ('s') ??? thanks
From: Wayne King on 16 Jul 2010 06:45 "mohamed saber" <joker_thedarknight(a)yahoo.com> wrote in message <i1osmo$4et$1(a)fred.mathworks.com>... > hello.....i'm a beginner in matlab........and i have a question > if i want to insert an (input)....its form is > ex: r=input('enter your password','s') > what is the mean of ('s') ??? > thanks Hi Mohamed, Welcome to MATLAB! Just curious, did you read the documentation for input() ? >>doc input In the documentation it states: strResponse = input(prompt, 's') returns the entered text as a MATLAB string, without evaluating expressions. The MATLAB doc is pretty thorough, so I do recommend that you read it. It will really help you as you learn MATLAB. It's telling you that if you use the optional second argument, 's', that any input is treated by MATLAB as a string. Even if you enter a number, MATLAB will treat that number as a string. For example: R = input('Enter your name:\n','s'); Enter John and then see what R contains. You can query its class by entering class(R) You will see that R is a character array. Now try R = input('Enter your name:\n'); Enter John again and see what happens. Why did that happen? Finally try: R = input('Enter a number between 1 and 10:\n'); % Enter any number class(R) R = input('Enter a number between 1 and 10:\n','s'); % Enter any number class(R) Wayne
|
Pages: 1 Prev: loading and using 2 mat files Next: find same values in two tables |