Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Can sparse matrix be used in place of zero matrix for space allocation in for loop?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!