how to implement following function in matlab?
显示 更早的评论
采纳的回答
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 个评论
I need solution of below equation and please give the matlab code for it.
n=size of matrix y

Change v(1:n) to reshape(v(1:n),1,[])
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))))))
please give me the exact code.
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.
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;
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.
give the code for below function when k (is not equal to) i .png)
.png)
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 Exchange 中查找有关 Mathematics 的更多信息
标签
尚未输入任何标签。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)

