hi, This is Pinaki. I am having a problem regarding the code execution time. The following code is taking almost 54 % of total run time to execute. Pls help me to victorize the following codes.
for m = 1:nbus
for n = 1:nbus
if m ~= n
Sij(m,n) = Vm(m)*conj(Iij(m,n))*BMVa;
end
end
end
Thanks, Pinaki

 採用された回答

Guillaume
Guillaume 2016 年 1 月 3 日

0 投票

Assuming Vm is a column vector (if not, change it so it is) and BmVa is a scalar:
assert(iscolumn(Vm), 'Vm must be a column vector');
assert(isscalar(BMVa), 'BMVa must be scalar');
Sijall = bsxfun(@times, Vm, conj(Iij) * BMVa);
This will calculate values for Sij even on the diagonal. If Sij is just zeros and you want that diagonal to stay 0:
Sij = Sijall .* ~eye(size(Sijall))
If it has values on the diagonal that you want to preserve:
Sij = Sij .* eye(size(Sij)) + Sijall .* ~eye(size(Sij))

1 件のコメント

PINAKI DHAR
PINAKI DHAR 2016 年 1 月 5 日
Thank you very much !!!!!!!!!!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by