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!