help-octave
[Top][All Lists]

## 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:1.9.2.23) 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:
```
```Hi,

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 ?

TIA

============ 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

end
end

_______________________________________________
Help-octave mailing list
https://mailman.cae.wisc.edu/listinfo/help-octave

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

```
```
Hi,

Sorry for not clear question
I was trying to do make vectorised ( fast) code like in this image :
http://commons.wikimedia.org/wiki/File:Mandelbrot_Creation_Animation_%28800x600%29.gif