Hello guys, I am coming across a problem when trying to formulate a differential equation to be simulated by ode23. My code iis as follows:
function dx=boost(t,x)global v_in R C L T ddx=zeros(2,1);if pwm(t,T,d)==1 dx(1) = v_in./L ; dx(2) = -x(2)./R*C ;endif pwm(t,T,d)==0 & x(1)>=0 dx(1) = (v_in - x(2))./L ; dx(2) = x(1)./C - x(2)./R*C ;endif pwm(t,T,d)==0 & x(1)<0 %#ok<*AND2>
dx(1) = 0 ; dx(2) = -x(2)./R*C ;enddx=[dx(1);dx(2)]; end
so the diff eq. takes three forms, as seen by the three if statements and they depend on the current outputs of another function. This other function is a pwm signal which controls a switch (this is being used to simulate a boost converter circuit but that is irrelevant).
the error 'Unable to perform assignment because the left and right sides have a different number of elements' refers to line 9 [ dx(1) = (v_in – x(2))./L ] . It makes no sense to me why I see this error since as far as I am aware both sides of the equations are scalar. Also I dont see this error for any other assigments in the function which all have similar forms.
Thank you.
Best Answer