using t in the ode function

1 次查看(过去 30 天)
tomer polsky
tomer polsky 2017-12-31
hello i am using the function of ode 45 but if for exmpale I i want to give value by the change of t,for exmaple i have this code :
function [ zigzag_simulation] = find_zigzag( t,x)
global R R1 C C1 L1 L2 U Duty_cycle alpha R_C R2 R_C1 V_diode R_diode
global A_T B_T C_T D_T V_desire f tspan
global A_a A_b B_a B_b
t_off=((alpha+1)*(f))^(-1);
ratio=rem(t,(1/f));
end
is it posbiile to use t ? becouse i have an error

回答(1 个)

Walter Roberson
Walter Roberson 2017-12-31
It is legal to use t in the ode function. However, you have used rem() in your calculations, which makes your output discontinuous. The ode function must be continuous to at least one more derivative than you use yourself or else MATLAB will detect the discontinuity. If the ode function is not continuous to at least one derivative further than that then ode45 will give the wrong answer but might not detect the discontinuity.
  2 个评论
tomer polsky
tomer polsky 2018-1-1
so how can i solve this problem ? I am sorry for my english it is not my first language
Walter Roberson
Walter Roberson 2018-1-1
We do not know how to fix the code. You have no comments in the code, and you did not give the equations to be solve.
Also, your function is defined as
function [ zigzag_simulation] = find_zigzag( t,x)
but you do not assign anything to zigzag_simulation.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by