Borrar filtros
Borrar filtros

how to store all values of a matrix variable during the loop

1 visualización (últimos 30 días)
theta=-pi/6:pi/180:pi/6;
phi=-pi/6:pi/180:pi/6;
[theta,phi]=meshgrid(theta,phi);
for rho=5:.025:50
[x,y,z]=sph2cart(theta,phi,rho);
xs=min(x(:)):0.03:max(x(:))+1;
ys=min(y(:)):0.15:max(y(:))+1;
zs=min(z(:)):0.15:max(z(:))+1;
end
I want to store the overall x,y&z and xs,ys&zs

Respuesta aceptada

Bob Thompson
Bob Thompson el 9 de Abr. de 2019
You need to add indexes to your outputs. Typically, it is usually appropriate to use your loop index value as the index, however, because your index is not always a real positive integer you will need to add some kind of counter into the loop.
c = 1;
for rho = 5:.025:50
[x(c),y(c),z(c)] =
xs(c) =
...
c = c + 1;
end
It may take some tweaking, but that's the basic idea.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by