I'm trying to create a matrix K with a certain function
My code is as follows
K=zeros(360*360,3);
for m = 0:360
for n = 0:360
for d=0:5
U1(1,1)= cos(m)+cos(m+n);
U1(1,2)= sin(m)+sin(m+n);
U1(1,3)=-d;
K(m,n)=(U1);
end
end
end
However I keep getting an error, "Subscript indices must either be real positive integers or logicals."
Can somebody explain how this can be fixed?
m
andn
start from0
, they should start from1
. – RashidK(m,n)=(U1);
. See my answer below. – Roney MichaelK=zeros([360,360,3]);
andK(m,n,:)=U1;
– Rashid