Regarding extra symbolic variable in differnent function

2 views (last 30 days)
if true
syms x y t;
syms x_0(t);
syms x_1(t);
syms x_2(t);
syms y_0(t);
syms y_1(t);
syms y_2(t);
syms R_0(x, y);
syms R_0(x, y);
syms R_0(x, y);
x_0(t) = -3.0 + 0.2 * sin(0.2 * t);
x_1(t) = 3.0 + 0.1 * sin(0.1 * t);
x_2(t) = 0.0 + 0.13 * sin(0.13 * t);
y_0(t) = 1.5 + 0.12 * sin(0.12 * t);
y_1(t) = 1.5 + 0.15 * sin(0.14 * t);
y_2(t) = -3.5 + 0.05 * sin(0.14 *t);
R_0 = (x - x_0)^2 + (y - y_0)^2 + 0.2;
R_1 = (x - x_1)^2 + (y - y_1)^2 + 0.2;
R_2 = (x - x_2)^2 + (y - y_2)^2 + 0.2;
v_x = (-5*(y - y_0)/((R_0)^2)) + (5*(y - y_1)/((R_1)^2)) + (5*(x - x_2)/((R_2)^2));
v_y = 5*(x - x_0)/(R_0^2) - 5*(x - x_1)/(R_1^2) + 5*(y - y_2)/(R_2^2);
ezplot(v_x);
end
I am trying to plot velocity as a composite function of x_i, y_i, R_i, while x_i and y_i is in terms of t, R_i is in terms of x, y, and t, how do I plot the path of my particle for this function, it seems like I either get error that symbolic variable must match or plotting requires not more than 2 variable
Thanks

Answers (1)

Walter Roberson
Walter Roberson on 14 Mar 2014
Is it correct that you have three free variables, x, y, and t ? If so then you cannot use ezplot() as ezplot() can only handle two free variables.
I would argue that your definition of R_0 is not correct (side note: you syms R_0 three times but miss R_1 and R_2). Your R_0 uses x_0 but x_0 is not a variable but rather a function, x_0(t), Therefore R_0 should be R_0(x, y, t). Likewise for consistency you should syms v_x and v_y as functions of x, y, and t and pass those variables into R_0, R_1, and R_2.
Once you have done that it should be clearer that you are trying to ezplot over three free variables.
Plotting with three free variables requires a 4D plot, and so requires representing a dimension through color or transparency or marker shape or marker size.

Community Treasure Hunt

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

Start Hunting!