Calling Konstants from string with name instead of index
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello everyone,
I have a string A containing konstants, which are calculated before.
A=[M_sig epsopen Emod sigopen]
Is there any way I can use the konstants name in equations instead of using the index? It would be great so I can recognice the used formula and don't need to check for the konstant name.
Like using
Emod*sigopen instead of A(3)*(4)
Thanks for your help
댓글 수: 0
채택된 답변
Image Analyst
2017년 8월 30일
Yes, if you make A a table or structure. Here's a structure example:
% Create sample data.
M_sig =1;
epsopen = 2;
Emod = 3;
sigopen = 4;
% Create a structure.
A= struct('M_sig', M_sig, 'epsopen', epsopen, 'Emod', Emod, 'sigopen', sigopen)
% Do the math.
output = A.Emod * A.sigopen
추가 답변 (1개)
James Tursa
2017년 8월 30일
편집: James Tursa
2017년 8월 30일
Are you just trying to do this?
[M_sig,epsopen,Emod,sigopen] = deal(A(1),A(2),A(3),A(4));
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!