フィルターのクリア

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

1 回表示 (過去 30 日間)
VANDANA GUPTA
VANDANA GUPTA 2019 年 4 月 9 日
回答済み: Bob Thompson 2019 年 4 月 9 日
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

採用された回答

Bob Thompson
Bob Thompson 2019 年 4 月 9 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by