Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Can sparse matrix be used in place of zero matrix for space allocation in for loop?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (0)
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!