Hi,
How can I create an array of 10 seconds start from 0 second increment by 0.1 seconds to 10 seconds?
Thank you
I tried to use seconds function but it didn't work I need this time for ode45 tspan

 Respuesta aceptada

Star Strider
Star Strider el 26 de Mayo de 2020

0 votos

Create the ‘tspan’ argument as a vector of more than two elements:
tspan = 0 : 0.1 : 10;
.

6 comentarios

Shahad Alomani
Shahad Alomani el 26 de Mayo de 2020
But matlab can't understand if 10 is a seconds and this is the issue!
Steven Lord
Steven Lord el 26 de Mayo de 2020
Why is that an issue? What problem / error / etc. are you experiencing when you're using a time span vector like Star Strider showed?
Shahad Alomani
Shahad Alomani el 26 de Mayo de 2020
no error, tspan is only take t0 and tf which final value, I need to increment it with 0.1 and matlab can't understand that 10 is in seconds. I need the 10 to be in unit of seconds.
Steven Lord
Steven Lord el 26 de Mayo de 2020
The ODE solvers neither know nor care what units the time span vector is in. It could be seconds. It could be nanoseconds. It could be years. It doesn't even need to represent time.
As long as you've written your ODE function so it handles correctly the time value with which the ODE solver calls it you should be okay.
Shahad Alomani
Shahad Alomani el 26 de Mayo de 2020
Thank you
Star Strider
Star Strider el 26 de Mayo de 2020
Shahad Alomani — As always, my pleasure!
Steven — Thank you!

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 26 de Mayo de 2020

Comentada:

el 26 de Mayo de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by