Clear Filters
Clear Filters

using t in the ode function

1 view (last 30 days)
tomer polsky
tomer polsky on 31 Dec 2017
Commented: Walter Roberson on 1 Jan 2018
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

Answers (1)

Walter Roberson
Walter Roberson on 31 Dec 2017
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 Comments
tomer polsky
tomer polsky on 1 Jan 2018
so how can i solve this problem ? I am sorry for my english it is not my first language
Walter Roberson
Walter Roberson on 1 Jan 2018
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.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!