I correct the code with help of Stackfriends, see the bold parts, if anybody else has the similiar stack.
Arithmeticaly, I should take w=1 and why get I w=2? Thanks a lot,
X=linspace(0,10,6);
Y=linspace(0,20,5);
Xstar=0;
Ystar=0;
**p=0;**
for i=1:length(X)-1
for j=1:length(Y)-1
if (Ystar==Y(j)) && (Xstar==X(i))
w=1;
else
w=2;
end
**p(i,j)=w**
end
end
Just a guess, but i think you want to loop through the arrays backwards. You should use the debugger and look at it step by step.
Try this:
Here is what you should do to solve the problem.
(I hope these instructions are still valid, I have a rather old version of MATLAB)