I am running a code for blasius equation on a flat plate.
    1 visualización (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Jarvis
 el 11 de Feb. de 2018
  
    
    
    
    
    Comentada: Jarvis
 el 11 de Feb. de 2018
            When ever I run the code nothing even shows in my workspace. How do I fix this please? I tried to use m=o, and m=m+1. How do I have matlab stop the loop after a certain number iterations?
x= 0.05:0.05:1;
spacing=0.001;
eta=0:spacing:10;
%All y calculated values
for i=1:length(x)
  for j=1:length(eta)
    y(i,j)=eta(j)*sqrt(x(i)*kinematic_viscosity/Us); %instead of plotting downwards, I am plotting 4 rows
    y25= eta(j)*sqrt(0.25*kinematic_viscosity/Us);
    y50= eta(j)*sqrt(0.50*kinematic_viscosity/Us);
    y75= eta(j)*sqrt(0.75*kinematic_viscosity/Us);
    y1= eta(j)*sqrt(kinematic_viscosity/Us);
  end
end
while 1
  fdoubleprime=A;
  for i=1:(length(eta)-1);
    f(i+1)=f(i)+spacing*fprime(i);
    fprime(i+1)=fprime(i)+spacing*fdoubleprime(i);
    fdoubleprime(i+1)=fdoubleprime(i)-((spacing)/2)*f(i)*fdoubleprime(i);
    ftripleprime(i+1)=-0.5*(f(i+1))*(fdoubleprime(i+1));
  end
  errorf=abs(fprime(end)-1)/1;
  if errorf<(10^-4)
    break
  end
  if fprime(end)>1
    A=A-0.00001;
  else
    A=A+0.00001;
  end
end
for k=1:length(x)
  U=Us*fprime;
  tauwall(k)=A*sqrt(((dynamic_viscosity)^2*(Us)^3)./(x(k).*kinematic_viscosity));
end
m=m+1
0 comentarios
Respuesta aceptada
  Image Analyst
      
      
 el 11 de Feb. de 2018
        To stop the loop after a certain number of iterations, use break.
loopCounter = 1;
maxIterations = 100000;  % Whatever you want.
for ......  % or while ......  however you're doing your looping.
    % code in loop...
    % At bottom of loop
    if loopCounter >= maxIterations 
        break;
    end
    loopCounter = loopCounter + 1;
end
Más respuestas (0)
Ver también
Categorías
				Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

