How to dynamically create symbolic variables?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kevin Bachovchin
am 13 Feb. 2014
Kommentiert: Walter Roberson
am 26 Mär. 2018
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 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 13 Feb. 2014
Bearbeitet: Azzi Abdelmalek
am 13 Feb. 2014
Edit
index = {'1'};
List = {'A','B','C'};
Temp=strcat(List,index)
A=sym(Temp)
3 Kommentare
Azzi Abdelmalek
am 13 Feb. 2014
Bearbeitet: Azzi Abdelmalek
am 13 Feb. 2014
index = {'1'};
List = {'A','B','C'};
Temp=strcat(List,index)
A=sym(Temp)
Weitere Antworten (2)
Roberto Germanà
am 15 Feb. 2017
Hello, can I create a matrx in the same way? e.g.
D = [D_11 D12
D_21 D_22]
1 Kommentar
Walter Roberson
am 26 Mär. 2018
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.
arpit patel
am 26 Mär. 2018
for i=1:2 for j=1:2 D(i,j)=sym(['D_' num2str(i) num2str(j)]) end end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Numbers and Precision finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!