I am trying to make a movie 60 frames long which shows a change in pressure profile over 60 months. I have a for-loop which calculates vector V for each month m=1:60. Then a nested for-loop which calculates the pressure at 101 equidistant points. This gives me 60 pressure profiles which I've been able to play frame-by-frame.
Problem: Now I want the first for-loop to restart whenever a pressure value drops below a value x. I've tried using an if-statement and a while-loop but I can't seem to get it to work/put it in the right place. Maybe this is because I've used the variable m in a lot of the subsequent calculations. I realize that the loop will never finish but I only need 60 iterations.
for m=1:N V(m) = (4*q)/(pi*((d-wm*(m))^2)); for i = 1:n P1(i,m) = p - r*g*H(i) - r/(2*(d-wm*(m)))*f*V(m)^2*D(i); end plot(P1(:,m),'r-') title('Pressure along pipeline', 'FontSize', 14); xlabel('Distance', 'FontSize', 14); ylabel('Pressure [Pa]', 'FontSize', 14); xlim([1 100]), ylim([0 p]) ss = strcat('Month',{' '},num2str(m)); legend(ss) grid M(:,m) = getframe; pause(0.1)end
Best Answer