iterating a vector with a loop?

2 views (last 30 days)
zack daniels
zack daniels on 21 Feb 2014
Edited: Andrei Bobrov on 21 Feb 2014
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.

Answers (1)

Andrei Bobrov
Andrei Bobrov on 21 Feb 2014
Edited: Andrei Bobrov on 21 Feb 2014
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

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!