how can I biult alphanumeric variable in for loop ???????????

조회 수: 2 (최근 30일)
nebi
nebi 2011년 7월 21일
i have 10 matrix with 20x20 dimension. firstly i must convert matrix to vector (each matrix)with dimension 1x400. then i must create matrix from them wit dimension 10x400... how can i built that using for loop.
i tried to this code but doesnt work.
i have A1,A2,A3,A4,...A10 matrix
file=[];
for i=1:10 k=int2str(i)
temp=strcat('A',k) name=[]; for j=1:10 name=[name temp(j,:)] end file(i)=name; end
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2011년 7월 21일
How did you build A1...A10 in the first place?

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

답변 (2개)

Friedrich
Friedrich 2011년 7월 21일
Hi,
you dont need a loop. You can do it this way:
A1 = rand(20);
A2 = rand(20);
result = [A1(:)';A2(:)'];
Or
C = cat(2, A1(:), A2(:))';

Walter Roberson
Walter Roberson 2011년 7월 21일
Please see this FAQ
  댓글 수: 3
Walter Roberson
Walter Roberson 2011년 7월 21일
Wish-list it ;-)
Oleg Komarov
Oleg Komarov 2011년 7월 21일
I was thinking to write "TUTORIAL: why is it a bad idea to create A1, A2,...An in a FOR loop."

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by