How to dynamically create symbolic variables?
3 次查看(过去 30 天)
显示 更早的评论
Hello,
I'm looking for a way to dynamically create symbolic variables.
For example with the code,
clear all
index = '1';
List = ['A','B','C'];
for i = 1:numel(List)
Temp = [List(i) index]
end
Is there a way I can create symbolic variables with the string stored in Temp?
Thank you, Kevin
0 个评论
采纳的回答
Azzi Abdelmalek
2014-2-13
编辑:Azzi Abdelmalek
2014-2-13
Edit
index = {'1'};
List = {'A','B','C'};
Temp=strcat(List,index)
A=sym(Temp)
3 个评论
Azzi Abdelmalek
2014-2-13
编辑:Azzi Abdelmalek
2014-2-13
index = {'1'};
List = {'A','B','C'};
Temp=strcat(List,index)
A=sym(Temp)
更多回答(2 个)
Roberto Germanà
2017-2-15
Hello, can I create a matrx in the same way? e.g.
D = [D_11 D12
D_21 D_22]
1 个评论
Walter Roberson
2018-3-26
D = sym('D_%d%d',[2,2]);
D(1,2) = sym('D12') ;
I do not know why the one entry is not to follow the pattern, but here it is.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!