|
From: | Jeffrey |
Subject: | Re: Gallery (or circulant matrices) |
Date: | Fri, 7 Jun 2013 20:49:26 -0700 (PDT) |
On Fri, Jun 7, 2013 at 10:15 PM, Jeffrey <[hidden email]> wrote:
Thanks, Markus. I'm afraid this didn't work. You can't subtract (1:length(v)) from (1:length(v))'. Did you mean to repmat them, somehow?On Fri, Jun 7, 2013 at 9:13 PM, Markus Appel [via Octave] <[hidden email]> wrote:
[hidden email]On 06/08/2013 02:26 AM, Jeffrey wrote:> Converting from Matlab, the "gallery" command to create circulant
> matrices is not implemented. Is there an Octave equivalent to
>
> K=gallery('circul',[4 -1 zeros(1,N-3) -1]);
>
> How does one find octave equivalents to Matlab statements? Thanks.I can't answer the general question of how to find equivalents, but in
the special case of this matrix (and if i understood the 'circul'
gallery function right) you should be able to substitute
K=gallery('circul',v)
by
K = v( 1 + mod( (1:length(v))' - (1:length(v)), length(v)) )
The _expression_ is basically creating an index matrix with shifted
columns and picking the elements out of your input vector v in the right
order.
Hope it helps,
Markus
_______________________________________________
Help-octave mailing list
https://mailman.cae.wisc.edu/listinfo/help-octave
If you reply to this email, your message will be added to the discussion below:http://octave.1599824.n4.nabble.com/Gallery-or-circulant-matrices-tp4653859p4653860.htmlTo start a new topic under Octave - General, email [hidden email]_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Hi Jeffrey,In newer versions of Octave (my guess is that you have an older version) there is a thing called broadcasting (http://www.gnu.org/software/octave/doc/interpreter/Broadcasting.html) which is probably why you had a problem and Markus didn't. I was working on a very unelegant solution myself, but Markus beat me to it. But here (I think) is another way to implement the circulant matrix that doesn't depend on broadcasting. (But is far less nice than Markus's one).function A = circul(v)n = size(v,2);A = zeros(n,n);for index = 0:n-1,A((0:(n-index-1))*(n+1)+index+1) = v(index+1);A((0:(index-1))*(n+1)+n*(n-index)+1) = v(index+1);endforendfunctionOr if you want to keep the same syntax as your matlab code, you can make a file called gallery.m put the function code in there, but replace the first line with something like:function A = gallery(opt, v)where opt would ostensibly be the string to choose other types of matrices? (I don't know the full behavior of gallery), but would just be ignored in this case.Hope this helps.James Sherman_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
http://octave.1599824.n4.nabble.com/Gallery-or-circulant-matrices-tp4653859p4653863.htmlIf you reply to this email, your message will be added to the discussion below:To start a new topic under Octave - General, email [hidden email]
To unsubscribe from Octave, click here.
NAML
[Prev in Thread] | Current Thread | [Next in Thread] |