variable to output name

조회 수: 4 (최근 30일)
Leyon
Leyon 2013년 11월 1일
편집: Matt J 2013년 11월 1일
name = 'adams'
c = 2x+4
I would like the value of "name" to be the variable for c. Therefore, instead of:
c = 2x+4
it would be:
adams = 2x+4
  댓글 수: 5
Leyon
Leyon 2013년 11월 1일
So the only option seems to be to create struct variables?
Thanks. i already knew this but was hoping there was another alternative so I could have a clean fieldname
Matt J
Matt J 2013년 11월 1일
편집: Matt J 2013년 11월 1일
It isn't the only option, but I recommended it to you here
as the safest one. There are dangers in using assignin, eval, load, etc... to create variables inexplicitly. See, for example,

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

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 1일
a=[2 4 5];
assignin('base','adams',a)
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2013년 11월 1일
But I don't see why it's important to change the name of your variable?

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by