Question on Numbering A1 - An?

조회 수: 2 (최근 30일)
Portgas Ace
Portgas Ace 2012년 9월 30일
how do i make the syntax for looping to have an output of A1, A2, A3, A4... A(n)? cant use A(n) since matlab will read it as an array.

답변 (2개)

Walter Roberson
Walter Roberson 2012년 9월 30일
  댓글 수: 1
Jan
Jan 2012년 9월 30일
@James: Such questions are asked such frequently, that they are collected in the FAQ. Please read them carefully.

댓글을 달려면 로그인하십시오.


Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 30일
편집: Azzi Abdelmalek 2012년 9월 30일
  • You can use A(n) if your data are numbers or char (same class),
example:
A=[10 20 30 40 ];
A(1)
A(2)
...
  • use A{n} if your data are both, or same class with different sizes
A={'color','price';'red','100';'green','200'}
  댓글 수: 3
Walter Roberson
Walter Roberson 2012년 9월 30일
If it is just output and not variable names, then
fprintf('A%d', n)
Azzi Abdelmalek
Azzi Abdelmalek 2012년 9월 30일
A=[3 5 6;5 3 4;6 7 9] %example
out=[];
for k=1:size(A,1);
out=char(out,[sprintf('A%d ',k) num2str(A(k,:))]);
end
disp(out)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by