How can I assign numbers to variables names?

조회 수: 5 (최근 30일)
Salah Eddine
Salah Eddine 2011년 3월 15일
Hi all,
How can I assign numbers to variables names without making them vector elements, for example how we write the following for loop: for i=1:5 Ai=i^2; end in such a way that the result is: A1=1 A2=4 . . A5=25

답변 (2개)

Paulo Silva
Paulo Silva 2011년 3월 15일
That's a very bad idea and there are already several similar questions at matlab answers.
  댓글 수: 8
Matt Fig
Matt Fig 2011년 3월 15일
I bet if we had just two hyper-linked lines show up somewhere in the process of posting a question, something like:
Are you wondering how to make variables like A1, A2, A3, A4, etc?
Are you wondering why == cannot find your number in an array?
That we could reduce these types of posts significantly. I don't think these two most common FAQs would make the Question submission process that much more cumbersome.
Jan
Jan 2011년 3월 16일
@Matt: Please send this to Helen (files@mathworks.com). Or better: Let the user confirm, that the question cannot be solved by reading these two links.

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


peter
peter 2011년 3월 15일
arrayfun(@(x) ['A',num2str(x)],[1:10],'uniformoutput',false)
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2011년 3월 15일
Which doesn't accomplishes what the OP asked.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by