[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: constructing a matrix from a vector
From: |
Francesco Potortì |
Subject: |
Re: constructing a matrix from a vector |
Date: |
Wed, 19 Oct 2011 11:18:43 +0200 |
>I wanted to execute element-wise subtraction.
>
>4 5 6 1 2 3
>7 8 9 -
>1 2 3
>4 5 6
>
>like that. ".-" doesn't do the job. If there is a better way, it's great.
>But my solution was correct at least using repmat :)
bsxfun should work, by reading the docs. But in Octave 3.2.4 on Debian
I see this:
a=[4 5 6; 7 8 9; 1 2 3; 4 5 6]
a =
4 5 6
7 8 9
1 2 3
4 5 6
octave> b=1:3
b =
1 2 3
octave> bsxfun(minus,a,b)
error: Invalid call to minus. Correct usage is:
-- Built-in Function: minus (X, Y)
octave> bsxfun("minus",a,b)
ans =
3 3 3
6 6 6
0 0 0
3 3 3
It's me or it's a bug?
--
Francesco Potortì (ricercatore) Voice: +39.050.315.3058 (op.2111)
ISTI - Area della ricerca CNR Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa Fax: +39.050.315.2040
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it
Re: constructing a matrix from a vector, Alasdair McAndrew, 2011/10/19