i want to store the values of bold part for each iteration of i.
1 次查看(过去 30 天)
显示 更早的评论
for i=1:3
for j=1:10
for k=1:10
x3(j,k)=X3(i)+p;
y3(j,k)=Y3(i);
p=k*l;
end
p=0;
Y3(i)=Y3(i)+l;
end
end
0 个评论
采纳的回答
Image Analyst
2021-12-9
I don't understand. The right hand size of the equations are being saved into little x3 and little y3 matrices. Of course you're overwriting for each iteration of i, so maybe you want three indexes:
for i=1:3
for j=1:10
for k=1:10
x3(i, j, k) = X3(i) + p;
y3(i, j, k) = Y3(i);
p=k*l;
end
p=0;
Y3(i) = Y3(i) + l;
end
end
2 个评论
Image Analyst
2021-12-9
What are your initial X3 and Y3 vectors?
What are the values of p, and l ("ell")?
Do you want x3 and y3 to be 3-D arrays where each 2-D plane is just one plane of the 3-D array?
Image Analyst
2021-12-9
Try this:
p = 0;
l = 2;
X3 = [-7.655; -6.189; -3.251]
Y3 = [1.393; 10.42; 6.639]
x3 = zeros(10, 10, 3);
y3 = zeros(10, 10, 3);
for plane = 1:3
for j = 1 : 10
for k = 1 : 10
x3(j, k, plane) = X3(plane) + p;
y3(j, k, plane) = Y3(plane);
p = k * l;
end
p = 0;
Y3(plane) = Y3(plane) + l;
end
end
x3
y3
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Detection 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!