Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Bob Thompson
Bob Thompson il 9 Apr 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.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by