How do I perform prelocation when creating an array using a for loop?

for example
Vcruise=[];
HPreq=[];
speedvalue=160;
for i=1:1:speedvalue
Vcruise=[Vcruise,i];
........
Ptotal_fwd=....
......
HPreq=[HPreq,PTotal_fwd];
end
and some graphical operations

 채택된 답변

David Hill
David Hill 2021년 6월 14일
speedvalue=160;
Vcruise=zeros(1,speedvalue);
HPreq=zeros(1,speedvalue);
for i=1:1:speedvalue
Vcruise(i)=i;
Ptotal_fwd=....
Preq(i)=PTotal_fwd;
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Linear Algebra에 대해 자세히 알아보기

제품

릴리스

R2016b

질문:

2021년 6월 14일

댓글:

2021년 6월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by