i want to store the values of bold part for each iteration of i.

1 回表示 (過去 30 日間)
Maimoona Asad
Maimoona Asad 2021 年 12 月 9 日
コメント済み: Image Analyst 2021 年 12 月 9 日
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

採用された回答

Image Analyst
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
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
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 ExchangeProgramming についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by