iterating a vector with a loop?
조회 수: 2 (최근 30일)
이전 댓글 표시
Basically, we want to append three values (HF , calc_length and handle ) as the next row of Data during each iteration (i.e. during each call to this function). Each of the three values should be added as a new row to Data. Take the Data that existed from the previous iteration, and adds the HF , calc_length and handle from this iteration to it. This will create a timeline of horizontal forces and lengths. We'll use this later to plot how we approached the optimal answer.
After i iterations, Data should have this structure:
Data = [ HF1 calc_length1 handle1;
HF2 calc_length2 handle2;
HF3 calc_length3 handle3;
... ...
HFi calc_lengthi handlei]
this is basically just part of a much larger function, with input HF. Im guessing i have to use a loop to satisfy the given instructions. I am not sure whether to use or for or a while loop but i need the iterations to go on until HF has reached a desired value( causing L, a given, to equal calc_length). I have been reading for hours and i still can't imagine how to put this together. any help is appreciated.
댓글 수: 0
답변 (1개)
Andrei Bobrov
2014년 2월 21일
편집: Andrei Bobrov
2014년 2월 21일
Data = [];
while 1
% here use your function for evalution HF, calc_length and handle
% ...
Data = [Data;HF, calc_length, handle];
if L == calc_length, break; end
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!