How to solve systems of non linear equation of dimensions 100 using ode45 matalb.
    6 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    RITIKA Jaiswal
 il 25 Set 2022
  
    
    
    
    
    Modificato: Torsten
      
      
 il 3 Ott 2022
            
how should i proceed if we want to implement its code?
2 Commenti
  Davide Masiello
      
 il 25 Set 2022
				It'd be best to post a first code attempt from your side, then we could try to help develop on that.
Risposta accettata
  Davide Masiello
      
 il 25 Set 2022
        If I were you, I would proceed substantially differently.
Since you need to solve 100 equations, it is unthinkable to cde them one by one.
The key here is indexing.
For instance
clear,clc
tspan = [0,7];
x0 = zeros(1,1000);      % substitute with correct initial conditions
dgn = ones(1,1000); dgn(251:750) = 1/2;
D = zeros(1000); D(logical(eye(1000))) = dgn;
options = odeset('Mass',D);
[t,X] = ode45(@odeFunc,tspan,x0,options);
function dxdt = odeFunc(t,x)
g = @(x) exp(40*x)+x-1;
dxdt(1,1)               = -g(x(1))-g(x(1)-x(2))+exp(-t);
dxdt(2:length(x)-1,1)   = g(x(1:end-2)-x(2:end-1))-g(x(2:end-1)-x(3:end));
dxdt(length(x),1)        = g(x(end-1)-x(end));
end
12 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



