Need to change one of my constants into a variable

1 Ansicht (letzte 30 Tage)
Tom
Tom am 4 Dez. 2011
The original question has been removed by the user.

Akzeptierte Antwort

Paulo Silva
Paulo Silva am 4 Dez. 2011
iter=1;
for HofB=2:100
%your code goes here
%don't forget to comment the HofB line of your code
TotLpRec(iter)=TotLp;
iter=iter+1;
end
plot(2:100,TotLpRec)
  2 Kommentare
Tom
Tom am 4 Dez. 2011
Many thanks Paulo :-)
Paulo Silva
Paulo Silva am 4 Dez. 2011
That code is simple but with even more iterations (more HofB values) it might become slow because TotLpRec isn't preallocated on memory, it's a vector that grows in size each iteration, this is the way with preallocated memory:
iter=1;
TotLpRec=zeros(99,1); %99 values will be saved and plotted
%you must always have a vector TotLpRec with numel(2:100) values or whatever %HofB will be
for HofB=2:100
%your code goes here
%don't forget to comment the HofB line of your code
TotLpRec(iter)=TotLp;
iter=iter+1;
end
plot(2:100,TotLpRec)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by