From: Eric Durant Subject: Re: sin(x) vs. sin [x] Date: 29 Mar 2000 00:00:00 GMT Message-ID: <38E252EF.BF6D629F@umich.edu> Content-Transfer-Encoding: 8bit References: <38E24B74.F81E969A@rohan.sdsu.edu> X-Accept-Language: en Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: usenet@eecs.umich.edu X-Trace: news.eecs.umich.edu 954356403 87187 141.213.12.216 (29 Mar 2000 19:00:03 GMT) Organization: EECS Dept. Univ. of Michigan Mime-Version: 1.0 Newsgroups: comp.soft-sys.matlab Christopher Mccoy wrote: > Can someone explain to me what the following does in matlab? > > x = 3.14159 > sin [x] > > NOTICE the space between sin and [ > > When I do this, I get three numbers. The assignment to the variable x has no effect on the output; on the second line you're referring to the character 'x', not the variable x. The bareword "[x]" is interpreted as a string of ASCII characters which sin() casts to doubles. The following 3 statements all mean the same thing: » sin [x] ans = 0.10599 0.58061 -0.94828 » sin('[x]') ans = 0.10599 0.58061 -0.94828 » sin(double('[x]')) ans = 0.10599 0.58061 -0.94828 The following shows the relationship between characters and their ASCII values (which are doubles in Matlab): » double('[x]') ans = 91 120 93 » char(ans) ans = [x] -- Eric Durant http://www.edurant.com/