필터 지우기
필터 지우기

How to dynamically create symbolic variables?

조회 수: 3 (최근 30일)
Kevin Bachovchin
Kevin Bachovchin 2014년 2월 13일
댓글: Walter Roberson 2018년 3월 26일
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

채택된 답변

Azzi Abdelmalek
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
Azzi Abdelmalek 2014년 2월 13일
편집: Azzi Abdelmalek 2014년 2월 13일
index = {'1'};
List = {'A','B','C'};
Temp=strcat(List,index)
A=sym(Temp)
Kevin Bachovchin
Kevin Bachovchin 2014년 2월 13일
Is there a way to ensure that the symbolic variables are real?

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

추가 답변 (2개)

Roberto Germanà
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
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.

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


arpit patel
arpit patel 2018년 3월 26일
for i=1:2 for j=1:2 D(i,j)=sym(['D_' num2str(i) num2str(j)]) end end

카테고리

Help CenterFile Exchange에서 Formula Manipulation and Simplification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by