10.07.2015 Views

Finding Potential Sites for Small-Scale Hydro Power in Uganda: a ...

Finding Potential Sites for Small-Scale Hydro Power in Uganda: a ...

Finding Potential Sites for Small-Scale Hydro Power in Uganda: a ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

time2=clock;%starts timer on clock 2.Search<strong>in</strong>g <strong>for</strong> height difference <strong>in</strong> a 3 X 3 cell w<strong>in</strong>dowThe search beg<strong>in</strong>s <strong>in</strong> the cell with highest elevation. From there it exam<strong>in</strong>es all eightsuround<strong>in</strong>g cells to f<strong>in</strong>d the next cell to go to. The first cell to exam<strong>in</strong>e is the upper left((x-1),(y-1)), seen from the highest elevation cell (x). Then it cont<strong>in</strong>ous to search counterclockwise untill all eight are exam<strong>in</strong>ed. The neighbour<strong>in</strong>g cell with greater slope than anyother of the neighbour<strong>in</strong>g cells, is the next cell, from where to cont<strong>in</strong>ue the search. Thenext cell must not be the previous cell, have the value of zero and have a value greaterthan current cell. After the first ten iterations have been per<strong>for</strong>med, it starts aga<strong>in</strong> at thecell with the second highest elevation. This is done repeatedly until all rivercells havebeen a start<strong>in</strong>g po<strong>in</strong>t.<strong>for</strong> l=cells:-1:1;%loop from 1 to number of "cells".x=order(l,1);y=order(l,2);%variables "x" & "y" are given the coord<strong>in</strong>ates from row "l" <strong>in</strong> "order".cell_height=0;%the variable "cell_height" is set to zero.height=0;%the variable "height" is set to zero.<strong>for</strong> m=1:10;%loop from 1 to 10.temp1=0;%the variable "temp1" is set to zero.highest_value=data(x,y);%the variable "highest_value" is set to the height value of current%coord<strong>in</strong>ates <strong>in</strong> "data".done=0;%sets the variable "done" to zero. Done is an <strong>in</strong>dicator show<strong>in</strong>g if%a logical exression has been per<strong>for</strong>med.if data((x-1),(y-1))>0 & data((x-1),(y-1))

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!