how to implement following function in matlab?

 採用された回答

Walter Roberson
Walter Roberson 2019 年 3 月 31 日

0 投票

M = @(i) abs(v(i)) .* sum( abs(v(1:n)) .* abs(y(i,1:n)) .* cos(q(i,1:n) + d(1:n) - d(i)) );
If n is the same as length(v) and size(y,2) and length(d) then the code can be written more compactly.

10 件のコメント

MUTYALA NAGABABU
MUTYALA NAGABABU 2019 年 3 月 31 日
I need solution of below equation and please give the matlab code for it.
n=size of matrix y
Walter Roberson
Walter Roberson 2019 年 3 月 31 日
Change v(1:n) to reshape(v(1:n),1,[])
MUTYALA NAGABABU
MUTYALA NAGABABU 2019 年 3 月 31 日
This is what i am getting solution on commad window.
I request you to give the full code based on above function.
M =
@(i)abs(v(i)).*sum(abs(reshape(v(1:n),1,[])).*abs(y(i,1:n)).*cos(angle(y(i,1:n)+angle(y(1:n)-angle(y(i))))))
the following is the code i have tried in matlab.
j=sqrt(2);
y=[1+j*1 1+j*2
2+j*3 3+j*3];
V=[1+j*0
1+j*3];
i=1;
n=2;
M = @(i) abs(v(i)) .* sum( abs(reshape(v(1:n),1,[])) .* abs(y(i,1:n)) .* cos(angle(y(i,1:n) + angle(y(1:n) - angle(y(i))))))
madhan ravi
madhan ravi 2019 年 3 月 31 日
MUTYALA NAGABABU
MUTYALA NAGABABU 2019 年 3 月 31 日
please give me the exact code.
Walter Roberson
Walter Roberson 2019 年 3 月 31 日
j=sqrt(2);
y=[1+j*1 1+j*2
2+j*3 3+j*3];
v=[1+j*0
1+j*3];
i=1;
n=2;
M = @(i) abs(v(i)) .* sum( abs(reshape(v(1:n),1,[])) .* abs(y(i,1:n)) .* cos(angle(y(i,1:n) + angle(y(1:n) - angle(y(i))))))
The only difference is that your formula was defined in terms of lower-case v, but you created a variable with upper-case V.
Note that what you posted gives a formula: it means "given a particular value for i, here is the calculation you need to make". The M that you get from my code is a formula : you have to invoke it with a particular value of i in order to get the answer. For example,
M(2)
The value that you pass in must not exceed the number of rows in y.
MUTYALA NAGABABU
MUTYALA NAGABABU 2019 年 3 月 31 日
j=sqrt(2);
y=[5.882-j*23.528 -2.941+j*11.764 -2.941+j*11.764
-2.941+j*11.764 5.882-j*23.528 -2.941+j*11.764
-2.941+j*11.764 -2.941+j*11.764 5.882-j*23.528];
v=[1.04+j*0
1+j*0
1.04+j*0];
i=2;
n=3;
M = @(i) abs(v(i)) .* sum( abs(reshape(v(1:n),1,[])) .* abs(y(i,1:n)) .* cos(angle(y(i,1:n) + angle((reshape(v(1:n),1,[]))-angle(v(i))))));
M(2)
M2=(abs(v2)*abs(v1)*abs(ybus(2,1))*cos((angle(ybus(2,1)))+del1-del2))+(abs(v2)*abs(v2)*abs(ybus(2,2))*cos(angle(ybus(2,2))))+(abs(v2)*abs(v3)*abs(ybus(2,3))*cos((angle(ybus(2,3))+del3-del2)))
the above is the code
after expanding the formula of M2 i have written the expansion,but i have not got M2 and M(2) as same;
MUTYALA NAGABABU
MUTYALA NAGABABU 2019 年 3 月 31 日
got the answer thank you so much for your great reply.
i request you to give the standard code of above for any no of variables.
MUTYALA NAGABABU
MUTYALA NAGABABU 2019 年 3 月 31 日
give the code for below function when k (is not equal to) i Screenshot (19).png
Walter Roberson
Walter Roberson 2019 年 3 月 31 日
noti = @(i) setdiff(1:n,i);
M = @(i) abs(v(i)) .* sum( abs(reshape(v(noti(i)),1,[])) .* abs(y(i,noti(i))) .* cos(angle(y(i,noti(i)) + angle(y(noti(i)) - angle(y(i))))))

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by