Creating a for loop that adds a number to a letter
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I'm trying to create a for loop that adds a number to a letter every time it loops. Here is my current code:
for count=1:99;
CM1=count;
CM2=count+1;
CM1X=['X',CM1]
CM2X=['X',CM2]
end
The problem that I am having is the X prints out fine, but the numbers print out as letters and then numbers and then characters. Here is what I am getting:
CM1X=
X
CM2X=
X .
.
.
CM1X=
X"
CM2X=
X/
and so on
Please help I'm not to sure what is going on.
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2013년 3월 8일
편집: Azzi Abdelmalek
2013년 3월 8일
for k=1:99
s{k}=sprintf('X%d',k)
end
댓글 수: 0
추가 답변 (2개)
bym
2013년 3월 8일
for insight into what is going on try
char(1:99)
does it look familiar to what you are getting?
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!