I am trying to use the code seen below to output an array titled as "Fatigue_Life" when the function of "mancof" changes from positive to negative. The input of j should be for each variable in the "de" array and the output should be an array for the value of i at which the "mancof" function becomes negative. The output array should be the exact same dimension as the input array. For example, de(1,1)=0.00486 should result in Fatigue_Life(1,1)=72 and so on until the array has been fully calculated. The code currently runs but I can not seem to get the output matrix as described above it seems to just be taking the last value? I created the input array "de" of all the same values for simplicity so the output array should also be of the same value, known to be 72. I hope what I would like to happen is clear. Please see the code below, any help will be greatly appreciated.
for j=de(:,i) if mancof>0 mancof=(sf/E*(2*i)^b)+(ef*(2*i)^c)-j; Fatigue_Life=i elseif mancof<0 fprintf('The Fatigue Life is: \n', Fatigue_Life) end end end
ii = (1:100)'; mancof = sf/E*(2*ii).^b + ef*(2*ii).^c - t; Fatigue_Life = find(mancof > 0);
ADD after Luke's comment
ii = (1:100)'; t = .00485 + .001*rand(30,1); % eg
mancof = bsxfun(@gt, sf/E*(2*ii).^b + ef*(2*ii).^c, t(:)'); [i1,j1] = find(mancof); Fatigue_Life = [i1,j1];
Play games and win prizes!Learn more