필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by