Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Maimoona Asad
Maimoona Asad le 9 Déc 2021
Commenté : Image Analyst le 9 Déc 2021
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

Réponse acceptée

Image Analyst
Image Analyst le 9 Déc 2021
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 commentaires
Image Analyst
Image Analyst le 9 Déc 2021
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 le 9 Déc 2021
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

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by