How to generate the equations automatically for multiple number of times
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
I want to generate these 4 equations (written below) multiple times,(V11, delta11, I11, phi11, V21,delta21,I21,Phi21 are measurements) For each sample of these 8 measurements i want to generate 4 more equations automatically.
e.g. if no of samples= 3, then i need to generate 12 equations automatically
Can anyone suggest a smarter way of doing that?
Thanks in advance! Farhan
F = [V11.*cos(delta11) - R1*I11.*cos(phi11)+X1*I11.*sin(phi11)-E3.*cos(delta31)+R3*I31.*cos(phi31)-X3*I31.*sin(phi31)
V11.*sin(delta11) - R1*I11.*sin(phi11)-X1*I11.*cos(phi11)-E3.*sin(delta31)+R3*I31.*sin(phi31)-X3*I31.*cos(phi31)
V21.*cos(delta21) - R2*I21.*cos(phi21)+X2*I21.*sin(phi21)-E3.*cos(delta31)+R3*I31.*cos(phi31)-X3*I31.*sin(phi31)
V21.*sin(delta21) - R2*I21.*sin(phi11)-X2*I21.*cos(phi11)-E3.*sin(delta31)+R3*I31.*sin(phi31)-X3*I31.*cos(phi31)]
댓글 수: 0
답변 (1개)
Image Analyst
2015년 5월 10일
Why not write a function:
function F = GenerateF(V11, delta11, I11, phi11, V21,delta21,I21,Phi21)
F = [V11.*cos(delta11) - R1*I11.*cos(phi11)+X1*I11.*sin(phi11)-E3.*cos(delta31)+R3*I31.*cos(phi31)-X3*I31.*sin(phi31)
V11.*sin(delta11) - R1*I11.*sin(phi11)-X1*I11.*cos(phi11)-E3.*sin(delta31)+R3*I31.*sin(phi31)-X3*I31.*cos(phi31)
V21.*cos(delta21) - R2*I21.*cos(phi21)+X2*I21.*sin(phi21)-E3.*cos(delta31)+R3*I31.*cos(phi31)-X3*I31.*sin(phi31)
V21.*sin(delta21) - R2*I21.*sin(phi11)-X2*I21.*cos(phi11)-E3.*sin(delta31)+R3*I31.*sin(phi31)-X3*I31.*cos(phi31)]
Then just call the function whenever you need to with whatever inputs you have at the time.
댓글 수: 4
Walter Roberson
2015년 5월 10일
function F = GenerateF(V11, delta11, I11, phi11, V21,delta21,I21,Phi21)
F = @(R1, R2, R3, X1, X2, X3, E3) [V11.*cos(delta11) - R1*I11.*cos(phi11)+X1*I11.*sin(phi11)-E3.*cos(delta31)+R3*I31.*cos(phi31)-X3*I31.*sin(phi31)
V11.*sin(delta11) - R1*I11.*sin(phi11)-X1*I11.*cos(phi11)-E3.*sin(delta31)+R3*I31.*sin(phi31)-X3*I31.*cos(phi31)
V21.*cos(delta21) - R2*I21.*cos(phi21)+X2*I21.*sin(phi21)-E3.*cos(delta31)+R3*I31.*cos(phi31)-X3*I31.*sin(phi31)
V21.*sin(delta21) - R2*I21.*sin(phi11)-X2*I21.*cos(phi11)-E3.*sin(delta31)+R3*I31.*sin(phi31)-X3*I31.*cos(phi31)];
The return value will be a function in R1, R2, R3, X1, X2, X3, E3, that will have "bound in" the values of the parameters that you passed to the generating function.
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!