help-octave
[Top][All Lists]

## >>> death=find((rand([size(newpop,1),1])<m).*move); %death to movements

 From: naryana.shankara Subject: >>> death=find((rand([size(newpop,1),1])

```the terminal keeps grumbling about this line: >>>
death=find((rand([size(newpop,1),1])<m).*move); %death to movements and for
the life of me I cannot see my error   here is my code (the offending line
is offset by spaces and ???):
%N= number of sites
%B=number of breeders
%p=migration propensity
%q=probability of mutation occuring
%b=offspring
%m=movement
function [xmean, n, xstd, occupied] = dispersal(N,B,p,q,b,m)
pop=[rand([N 1]) (1:N)'];
for t=1:1000
xmean(t) = mean(pop(:,1));
xstd(t) = std(pop(:,1));
n(t) = length(pop(:,1));
if t/20==floor(t/20)
figure(1); %generate new plot every 20th iteration
subplot(2,1,1);plot(1:t,xmean);
ylabel('Mean Dispersal Rate');
title (['Mortality=' num2str(m)]);
subplot(2,1,1);plot(1:t,n);
xlabel('Time');
ylabel('Population Size');
drawnow;
end
%randomize number of idividuals using randperm
ind=randperm(size(pop,1)); %use onlt the first column
pop=pop(ind,:); %reorder population by the random number generated above
disaster =find(rand([N 1])&lt;p); %destroy some sites if number &lt; p
then
use it in disasterplaces
disasterplaces=intersect(pop(:,2),disaster); %intersect the array (2nd
column) and disaster
for i =1:length(disasterplaces) %kill residents of disasterplaces
f=find(pop(:,2)==disasterplaces(i));
pop(f,:)=[];
end;
for i=1:N %competition among the living between 1 and N
potentialbreeders=find(pop(:,2)==i);
if length(potentialbreeders)>B %remover the excess breeders
pop(potentialbreeders(B+1:end),:)=[];
end;
end;
occupied(t)=length(unique(pop(:,2)))/N;
if size(pop)==0 break; %break loop when population becomes extinct
end;
newpop=[]; %collect offspring
for i = 1:b %loop between 1 and b-offspring
newpop=[newpop; pop];
end;
mutate=rand([size(newpop,1),1]) < q %probability of mutation occuring
use
1st column when no mutation occur
newpop(:,1)=newpop(:,1).*(~mutate)+rand([size(newpop,1),1]).*mutate;
%mutate might be an unequal array use ~
move=rand([size(newpop,1),1])< newpop(:,1)
newlocation=ceil(N*rand([size(newpop,1),1]));
newpop(:,2)=(newpop(:,2).*(~move)+newlocation.*move %use 2nd column of
newpop remains same if no movement else use predefined location

??????death=find((rand([size(newpop,1),1])<m).*move); %death to
movements?????????????????

newpop(death,:)=[];
pop=newpop;
end;

any help would be greatly appreciated

--
View this message in context:
http://octave.1599824.n4.nabble.com/death-find-rand-size-newpop-1-1-m-move-death-to-movements-tp4675354.html
Sent from the Octave - General mailing list archive at Nabble.com.

```