iterating a vector with a loop?

2 Ansichten (letzte 30 Tage)
zack daniels
zack daniels am 21 Feb. 2014
Bearbeitet: Andrei Bobrov am 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.

Antworten (1)

Andrei Bobrov
Andrei Bobrov am 21 Feb. 2014
Bearbeitet: Andrei Bobrov am 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

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by