[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help filling a matrix
From: |
Mark P. Esplin |
Subject: |
Re: Help filling a matrix |
Date: |
Tue, 11 May 2004 14:26:10 -0400 |
User-agent: |
KMail/1.5.4 |
Thanks,
I think reshape will give me what I want. I did want to fill the the
whole
matrix and not just the diagonal. Sorry my example was missleading.
-Mark Esplin
On Tuesday 11 May 2004 10:52, you wrote:
> I think this should do it:
>
> z2d=reshape(z,n,n);
>
> But... in your example you're only filling the main diaganol so it's
> doubtful that reshape would be faster. Is this what you want?
>
> regards,
> ryan peterson
>
>
>
> From: "Mark P. Esplin" <address@hidden>
>
> >To: address@hidden
> >Subject: Help filling a matrix
> >Date: Tue, 11 May 2004 10:12:34 -0400
> >
> > I have the data that will make a gray scale image in three separate 1-D
> >arrays, x, y, z. The value of the i'th pixel is z(i) with the x and y
> >corrdinates in x(i), and y(i). The following does what I want, but is
> >there
> >a way of doing it without a loop?
> >
> >n = length(x);
> >z2d = zeros(n,n);
> >for i=1:n
> > z2d(x(i),y(i)) = z(i);
> >endfor
> >
> > -Mark Esplin
> >
> >
> >
> >-------------------------------------------------------------
> >Octave is freely available under the terms of the GNU GPL.
> >
> >Octave's home on the web: http://www.octave.org
> >How to fund new projects: http://www.octave.org/funding.html
> >Subscription information: http://www.octave.org/archive.html
> >-------------------------------------------------------------
>
> _________________________________________________________________
> Best Restaurant Giveaway Ever! Vote for your favorites for a chance to win
> $1 million! http://local.msn.com/special/giveaway.asp
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------