Can’t get matrix to populate first column
So I’m trying to create a matrix that changes between 3 possible values based on modified values of a different matrix, here’s the code:
z=linspace(1,cap,cap)’;
y=linspace(1,cap,cap)’;
f=@(x,y) x-y;
M=f(z.’,y);
p=zeros(size(M));
z1=z+1; %dem went to patch 1 and found food
z1(z1>cap)=cap;
for j=1:15
for k=1:15
if M(j,z1(k))>0
p(j,z1(k))=0.9;
elseif M(j,z1(k))<0
p(j,z1(k))=0.1;
else
p(j,z1(k))=0.5;
end
How do I get that first column to populate correctly?
I have multiple of these p matrices with different modifiers and some of them populate the entire matrix while others are missing a column or rowSo I’m trying to create a matrix that changes between 3 possible values based on modified values of a different matrix, here’s the code:
z=linspace(1,cap,cap)’;
y=linspace(1,cap,cap)’;
f=@(x,y) x-y;
M=f(z.’,y);
p=zeros(size(M));
z1=z+1; %dem went to patch 1 and found food
z1(z1>cap)=cap;
for j=1:15
for k=1:15
if M(j,z1(k))>0
p(j,z1(k))=0.9;
elseif M(j,z1(k))<0
p(j,z1(k))=0.1;
else
p(j,z1(k))=0.5;
end
How do I get that first column to populate correctly?
I have multiple of these p matrices with different modifiers and some of them populate the entire matrix while others are missing a column or row So I’m trying to create a matrix that changes between 3 possible values based on modified values of a different matrix, here’s the code:
z=linspace(1,cap,cap)’;
y=linspace(1,cap,cap)’;
f=@(x,y) x-y;
M=f(z.’,y);
p=zeros(size(M));
z1=z+1; %dem went to patch 1 and found food
z1(z1>cap)=cap;
for j=1:15
for k=1:15
if M(j,z1(k))>0
p(j,z1(k))=0.9;
elseif M(j,z1(k))<0
p(j,z1(k))=0.1;
else
p(j,z1(k))=0.5;
end
How do I get that first column to populate correctly?
I have multiple of these p matrices with different modifiers and some of them populate the entire matrix while others are missing a column or row matrix, matrix array MATLAB Answers — New Questions