how to store time loop i creat save matrix but stored only that last iteration at final time
    5 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Abdulrahman Mohamed
 el 16 de Feb. de 2022
  
    
    
    
    
    Editada: Abdulrahman Mohamed
 el 16 de Feb. de 2022
            How to save loop with time step while
0 comentarios
Respuestas (1)
  KSSV
      
      
 el 16 de Feb. de 2022
        % timestep 
time = zeros([],1) ;  % variable to save time 
t=ti;%intitial time step
count=1;
time(count) = t ; 
while t < tf
    for i=2:(nx-1)%should be 2D
        for j=2:(ny-1)
            Grid_order =(j-1)*nx +i;
            k=Grid_order;
            B(k,1)= alpha*Pcurrent(k,1);
            B(Prod_Grid_order,1)=Pprod;
        end
    end
    % Solution for Future time pressure
    Pnplus1=A\B;
    Prod_Grid_order=(6-1)*nx + 6;
    Pnplus1(Prod_Grid_order,1)=Pprod;
    Pcurrent=Pnplus1;
    Psave(:,j)=Pcurrent; % store matrix 
    t=t+dt;
    count = count+1 ; 
    time(count) = t ; 
end 
Or else you can create your own time step instead of saving, as the time step is dt always. 
time = ti+(1:count)*dt ; 
0 comentarios
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!

