How to generate the equations automatically for multiple number of times

3 vues (au cours des 30 derniers jours)
Farhan
Farhan le 10 Mai 2015
Commenté : Farhan le 11 Mai 2015
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)]

Réponses (1)

Image Analyst
Image Analyst le 10 Mai 2015
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 commentaires
Walter Roberson
Walter Roberson le 10 Mai 2015
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.
Farhan
Farhan le 11 Mai 2015
Hi Image Analyst,
All the inputs to GenereateF i.e. V11, delta11, I11, phi11, V21,delta21,I21,Phi21 are my measurement data. In order to solve these equations generated by GenerateF using (non-linear least square) algorithm one need at least 3 samples of input data.(No of Eqs>No of unknowns)
Therefore 4*3=12 eqs i want to first generate these 12 equations automatically and then will be used in least square algorithm. (other option is to write by hand, but imagine if no of samples = 10, so i cant write 40 equations manually)
Any suggestion how to generate multiple no of equations (for loop may be, but my V11, delta11.... are changing (due to next sample of data) )

Connectez-vous pour commenter.

Catégories

En savoir plus sur Systems of Nonlinear Equations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by