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

2 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Image Analyst
Image Analyst el 9 de Dic. de 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 comentarios
Image Analyst
Image Analyst el 9 de Dic. de 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 el 9 de Dic. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by