create a new variable whos name is conditional
이전 댓글 표시
Hi. How can I creat a new variable whose name I dont know yet. A simple example is below. Thanks
>> [a,b,c]=xlsread('myfile.xlsx')
a =
[]
b =
'new_var'
c =
'new_var'
.... now I want to create a variable whose name is the same as the string taken from b . i.e I want to creat a variable with name new_var . and then give it a value ( new_var=10). How?
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2014년 2월 9일
편집: Azzi Abdelmalek
2014년 2월 9일
Look at this link http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
You can do it like:
varname='new_var'
assignin('base',varname,[1 2 3])
new_var
But this is not a good idea like you can read it in the link
댓글 수: 2
Milad
2014년 2월 9일
Azzi Abdelmalek
2014년 2월 9일
I don't know the name of the variable
[a,b,c]=xlsread('myfile.xlsx')
assignin('base',b,[1 2 3])
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!