[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newbie - matrix fill from vectors

From: Adam Majewski
Subject: Re: newbie - matrix fill from vectors
Date: Fri, 04 Nov 2011 18:57:35 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20110921 Thunderbird/3.1.15

On 03.11.2011 22:20, Juan Pablo Carbajal wrote:
On Thu, Nov 3, 2011 at 9:28 PM, Adam Majewski<address@hidden>  wrote:

I want to have am matrix of complex numbers representing quadrant plane

# integer coordinate = pixels
iSide =5; # side of matrix

# world ( float) coordinate - dynamical (Z) plane
dSide= -2.0
Zxmin = -dSide;
Zxmax = dSide;
Zymin = -dSide;
Zymax = dSide;

# vectors of coordinate
vZx = linspace(Zxmin,Zxmax,iSide)
vZy = linspace(Zymin,Zymax,iSide)

mZ=zeros(iSide,iSide); # my matrix to fill

How can I fill this matrix ( not using 2 loops) from vectors ?



============ loop code =========

stepy = (Zymax - Zymin)/(iSide - 1); # pixel height
stepx = (Zxmax - Zxmin)/(iSide - 1); # pixel width

# scan all pixels of image and compute color
for iy = 1:iHalfSide
  Zy = Zymax - (iy-1)*stepy; # invert y axis
  for ix= 1:nx
    Zx = Zxmin + ix*stepx; # map from screen to world coordinate


Help-octave mailing list

What should be in mZ?
In your code you create Zy and Zx, but do not fill mZ.


Thx for answer.
Sorry for not clear question
I was trying to do make vectorised ( fast) code like in this image :

I have made :
Can I vectorise this code ?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]