for loop in matlab
조회 수: 1 (최근 30일)
이전 댓글 표시
syms Av Riopamp Riminus Rf Ro omega Ciminus
h11=Riopamp+((Riminus*Rf)/(Riminus+Rf))
h12=Riminus/((Riminus+Rf))
h21=-(((Av*Riopamp)/Ro)+(Riminus/Rf))
h22=(Ro+Riminus+Rf)/((Ro*(Riminus+Rf)))
h11new=subs(h11,Riminus,Riminus-(1/(1i*omega*Ciminus)))
simplify(h11new)
how to repeat this code(bottom) for all h12 h21 h22?
h11new=subs(h11,Riminus,Riminus-(1/(1i*omega*Ciminus)))
댓글 수: 0
답변 (1개)
Santosh Fatale
2022년 4월 7일
Hi Grace,
I understand that you have four symbolic variables h11, h12, h21, h22. You expressed the respective expression for each of these variables using other symbolic variables. You want to substitute new value for one of the symbolic variable which is a part of the expression and evaluate expression of variables h11, h12, h21, and h22 for this new value. I would like to suggest you to use struct datatype as follows to ease tasks which you want to achieve.
syms Av Riopamp Riminus Rf Ro omega Ciminus
T = struct;
T.h11=Riopamp+((Riminus*Rf)/(Riminus+Rf))
T.h12=Riminus/((Riminus+Rf))
T.h21=-(((Av*Riopamp)/Ro)+(Riminus/Rf))
T.h22=(Ro+Riminus+Rf)/((Ro*(Riminus+Rf)))
h11new=subs(T,Riminus,Riminus-(1/(1i*omega*Ciminus)))
for iterVar1 = 1 :2
for iterVar2 = 1: 2
simplify(h11new.("h"+iterVar1+iterVar2))
end
end
The individual fields of the structure, which are variables in your case, can be accessed by dot notation as follows:
>> T.h11
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Numbers and Precision에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!