syms x y
ezplot((x^2 + y^2)^4 == (x^2 - y^2)^2, [-1 1])
hold on
xlabel('x axis')
ylabel('y axis')
grid on
hold off
es, the Heaviside function is 0.5 at zero this gives it the appropriate mathematical
properties. You can shift it to compare values other than zero. This is a standard technique.
In Matlab R2012a+, you can take advantage of assumptions in addition to the normal
relational operators. To add to @AlexB's comment, you should convert the output of any
logical comparison to symbolic before using isAlways:
isAlways(sym(x<0))
In your case, x is obviously not "always" on one side or the other of zero, but you may still
find this useful in other cases.
/ 0 if x < 0,
m(x) = | -2x(x - 3/2) if 0 x < 1,
| 1 + (x - 1) if 1 x < 3/2,
\ x - 1/4 if x 3/2.
So in matlab if I have some variable x with some values, i.e.
x = -1:0.01:2;
then I can formulate the above as:
m = ...
(0 ) .* (x < 0 ) + ...
(-2*x.^2.*(x-3/2)) .* (0 <= x & x < 1 ) + ...
(1+(x-1).^2 ) .* (1 <= x & x < 3/2) + ...
(x-1/4 ) .* (x >= 3/2 );
Now, I can show a plot:
plot(x,m);
syms t
y1=t^2
y2=t^2-16
fg=figure
ax=axes;
ez1=ezplot(char(y1),[-8,8])
hold on
ez2=ezplot(char(y2),[-8,8])
legend('y1=t^2','y2=t^2-16')
set(ez1,'color',[1 0 0])
title(ax,['y1=t^2' ' y2=t^2-16'])
syms g h t
assume(g > 0)
solve(h == g*t^2/2, t)
assume(x < -1 | x > 1)
solve(x^5 - (565*x^4)/6 - (1159*x^3)/2 - (2311*x^2)/6 + (365*x)/2 + 250/3, x)