필터 지우기
필터 지우기

How to generate the equations automatically for multiple number of times

조회 수: 1 (최근 30일)
Farhan
Farhan 2015년 5월 10일
댓글: Farhan 2015년 5월 11일
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)]

답변 (1개)

Image Analyst
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
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.
Farhan
Farhan 2015년 5월 11일
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) )

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by