Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Can sparse matrix be used in place of zero matrix for space allocation in for loop?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi mathworks commnunities,
I developed an optimization model in matlab but i observed the memory allocation of the model is much which slow down the computational time.
My question is if it is possible to use sparse matrix in place of zero matrix for space allocation in for loop statement in order to reduce memory usage?
Part of the code is:
% Wind Generation Constraint
Pwind=zeros(8760,1); % is possible to change to sparse( 8760,1) without altering the duty of for loop?
for ll = 1:nHours
if WindVelocity(ll)<Vci
Pwind(ll)=0;
elseif WindVelocity(ll)>Vco
Pwind(ll)=0;
elseif Vr<WindVelocity(ll)<Vco
Pwind(ll)=20;
elseif Vci<WindVelocity(ll)<Vr
Pwind(ll)=20*((WindVelocity(ll)-Vci)/(Vr-Vci));
end
end
Thanks,
Mic
0 件のコメント
回答 (0 件)
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!