Hi,
I'm calling a events function as below for ode45:
option2 = odeset('Events', @comp);
[time, Y] = ode45(dYdt, tspan, y0, option2);
The function looks as follow:
function [position, isterminal, direction] = comp(t, Y)
x = Y(1); %x-coordinate
y = Y(2); %y-coordinate
xL = x*cos(Par.theta) + y*sin(Par.theta);
xL1 = Par.x1*cos(Par.theta); %[m]
xL2 = Par.x2*cos(Par.theta); %[m]
position = [xL1-xL; xL2-xL; Par.S-Y(end,1)];
isterminal = [0; 0; 1];
direction = [1; 1; -1];
end
I keep getting the error "Undefined variable "Par" or class "Par.theta"." When I substitute the variables with other variables not in a structure I then get the error "Not enough input arguments", but I've checked each variable is accounted for.
Anyone one with a suggestion on how to correctly call a structure variables' values in a function would be appreciated.
Thanks
Best Answer