Set axes properties in a loop
조회 수: 11 (최근 30일)
이전 댓글 표시
Many times I want to set the axes properties with a loop. Here is an example of how I am currently doing it:
ax = gca;
axs = 'XYZ';
for k = 1:3
ax.([axs(k) 'Label']).String = sprintf('A_%d (g/cm^2)',k); % label axis units
end
Is there a better way to do this?
댓글 수: 0
답변 (1개)
Thorsten
2016년 8월 16일
편집: Thorsten
2016년 8월 17일
In this case I think that the for loop is kind of overkill. Without a loop, it is much easier to understand what's going on:
ax.XLabel.String = 'A_1 (g/cm^2)';
ax.YLabel.String = 'A_2 (g/cm^2)';
ax.ZLabel.String = 'A_3 (g/cm^2)';
댓글 수: 3
Thorsten
2016년 8월 17일
I see. Please post the complete example such that we can run the code. For example, nodelist is missing, and a command like plot or surf to show the data.
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!