Re: how to use ones(A)?
- To: mathgroup at smc.vnet.net
- Subject: [mg88248] Re: how to use ones(A)?
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Tue, 29 Apr 2008 06:51:23 -0400 (EDT)
On 4/28/08 at 4:40 AM, second_444 at 126.com (second_444) wrote:
>v=[1 2 3];a=ones(v) the result is: a(:,:,1) =
Nonsense as should be expected when you don't use appropriate syntax.
If you type
v=[1 2 3]
into a new cell and execute it you will get an error.
This syntax tells Mathematica to compute the product of 1, 2 and
3 then evaluate a function with no name with an argument equal
to 6.
I am guessing you want
v= {1,2,3
rather than what you wrote.
Now after using a correct assignment the syntax you use to get a
result isn't meaningful either. The characters "(" and ")" are
used for grouping. The syntax a(stuff) tells Mathematica to
multiply the stuff between "(" and ")" by a. I doubt this is
what you wanted.
v[x] is a function v to be evaluated at x
v[[x]] says return the item x from list v
v(x) says multiply x by v
v{x} says multiply the list with one element x by v and will
return {x v}