heaviside.m is slow
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am using heaviside.m inside the right hand side function for ode45. There is a for loop within the right hand side function that gets evaluated at each time point the integrator takes a step into. I profiled the result because the code has gotten much slower. This is where I learned that heaviside.m is very slow.
We can use logical indexing to replace the heaviside.m function. I did this and this is much faster but not as fast as it should be... Unfortunately, the for loop cannot be vectorized because the system is a linear system with a non linear right hand side vector.
Do you think the logical indexing is the fastest way to map a real number to 0 or 1, depending on it sign, in MATLAB? Also, could there be any speed up with the for-loop, if we cannot get rid of it?
Thanks a lot for your help!
Sincerely,
Tae
2 comentarios
Mike Croucher
el 19 de Abr. de 2022
Hi Tae
You are much more likely to get an answer if you post your code. Help us help you: Post your code - (mathworks.com)
We can't promise anything of course but it definitely helps.
Best Wishes,
Mike
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!