Vectorization of a function with system of ODE's
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
George Bashkatov
el 17 de Abr. de 2021
Respondida: Walter Roberson
el 17 de Abr. de 2021
I want to modify famp so that it accepts a vector of y values, and reshapes the values to 2 columns, and then computes values for each row, but I don't know how I can do it. Can you help me, please?
function dydz = famp(pa,N0,pe,se,k,y,z)
k=Par.N0*pa/(pa+pe);
dy1 = y(1).*(pa.*N0+(pa+pe).*(k.*y(1)./(y(1)+y(2)+1)));
dy2 = y(2).*se.*(k.*y(1)./(y(1)+y(2)+1));
dydz = [dy1; dy2];
What can you advice to read to understand vectorization and optimization in a whole? By the way I know about documentation, but it is not enough.
0 comentarios
Respuesta aceptada
Walter Roberson
el 17 de Abr. de 2021
function dydz = famp(pa,N0,pe,se,k,y,z)
y = reshape(y, [], 2);
k=Par.N0*pa/(pa+pe);
dy1 = y(:,1).*(pa.*N0+(pa+pe).*(k.*y(:,1)./(y(:,1)+y(:,2)+1)));
dy2 = y(:,2).*se.*(k.*y(:,1)./(y(:,1)+y(:,2)+1));
dydz = reshape([dy1, dy2],[],1);
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!