How to generate the equations automatically for multiple number of times
2 次查看(过去 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!