I've run an experiment where a machine exerts a force on a bridge until it breaks. I need to cycle through my entire data set and calculate the toughness until I've hit the breaking point. The toughness is calculated by summing up all the rectangles under my load vs. distance curve. (Basically the integral) However, I have not been able to find a reasonable way of doing so and my current loop is an infinite loop and I'm not sure why.
%Initializing variables
bridge1Data = xlsread('Bridge1Data.xlsx', 'A2:C2971');bridge2Data = xlsread('Bridge2Data.xlsx', 'A2:C1440');bridge1Load = bridge1Data(:, 2);bridge2Load = bridge2Data(:, 2);bridge1Dist = bridge1Data(:, 3);bridge2Dist = bridge2Data(:, 3);[row1, col1] = size(bridge1Dist);[row2, col2] = size(bridge2Dist);bridge1Disp = zeros(row1, col1);bridge2Disp = zeros(row2, col2);fdValue1 = 0.000407350000000029;&Main code%Displacement
for k = 2:length(bridge1Dist) bridge1Disp(k-1, 1) = bridge1Dist(k, 1) - bridge1Dist(k-1, 1);end%Max Load Bridge 1
maxLoad1 = 0;for n = 1:length(bridge1Load) for k = 1 if bridge1Load(n, k) > maxLoad1 maxLoad1 = bridge1Load(n, k); end endend%Cycle through data till failure, change proj data
totalRect1 = 0;for j = 2:length(bridge1Disp) while bridge1Disp(j, 1) ~= fdValue1 rectangle = (bridge1Disp(j, 1) - bridge1Disp(j-1, 1))*... ((bridge1Load(j, 1) + bridge1Load(j-1, 1))/2); totalRect1 = totalRect1 + rectangle; endend
Basically, I make an array for the load and distance the machine pushes down on the bridge, assign a 'Failure Distance' value (fdValue). I then calculate displacement, calculate the maximum load, through the variable 'rectangle' and sum them all up in 'totalRect1', and use that to calculate the toughness by finding the area under the curve. Is anyone able to see why the loop is an infinite loop? Thanks
Best Answer