Hello. I first create a matrix by using logspace and I convert it to a 50 row and 1 column matrix. I then create a for loop that polpulates column 2 per the number obtained from my for loop, (50 iterations). The values from my column one are used inside the for loop. The first iteration is done perfectly. Values (1,1) was used and populated value (1,2) . When my for loop continues to iteration 2 to 50, the rest of colum 2 is populted by 1's. Can someone please help me understand why it does not do as it first did?
format long h = logspace(-9, -4); h = h' for j = 1 : 50 eps = h(j,1) for i = 1 : 101 c = xm; xm = (xa + xb) / 2; t(i) = abs((xm - c ) / xm); if t(i) <= eps break end if t(i) > eps if y(xa) < 0 && y(xm) > 0 xb = xm; end if y(xa) > 0 && y(xm) < 0 xb = xm; end if y(xm) < 0 && y(xb) > 0 xa = xm; end if y(xm) > 0 && y(xb) <0 xa = xm; end end if i == 100 break end i = i + 1; end h(j, 2) = (i) j = j + 1 end p = h(:,1); k = h(:,2); semilogx(p,k)
Best Answer