I have solved a system of differential equations and got the answer:
x(t) = -C1exp(-t) + C2exp(3*t)/3
y(t) = C1exp(-t) + C2exp(3*t)
X and y depend on t. How can I plot the y(x) graph?
Related
I have 2 equations for curve:
x^2 = 8y
y^2 = 8x
I have:
syms x y
f1 = y^2 - (8*x);
f2 = x^2 - (8*y);
x0 = 0
h1 = ezplot(f1);
hold on
h2 = ezplot(f2);
What is the best way to find the area between these two curves and shade the area between it?
I have a discrete ODE, where u is the input and y is the output and dy is the derivative of y.
dy = #(y, u) 229.888852 - 0.050251*y + 3.116311*u + 0.000075 * y^2
I want to simulate this system with a ODE-solver e.g ODE45. But ODE45 requries a time vector t e.g
tspan = [0 5];
y0 = 0;
[t,y] = ode45(#(t,y) 2*t, tspan, y0);
And I don't have the t in my discrete ODE. I found it difficult to use ODE45 or other ODE-solvers in MATLAB / Octave because they don't handle discrete ODE's.
My question is simple:
How to simulate a discrete ODE in MATLAB with adaptive step size?
I would like to symbolically solve an integral in Matlab. But Matlab doesn't solve my equation.
The term I want to take integral is : x ^2 * exp(-lambda*x)/ (x+w+tau)
Here is my code:
syms x
f = x ^2 * exp(-lambda*x)/ (x+w+tau);
F = int(f,0,lambda)
pretty(F)
Matlab does not solve it, instead gives me the folowing:
F =
int((x^2*exp(-lambda*x))/(tau + w + x), x, 0, lambda)
I'm a newbie to matlab. Now I'm trying to plot a 2d quadratic equation. Such as ax^2 + by^2 + cxy + dx + ey + f = 0.
The way I try is to use
x = linspace(-1,2,100);
and transform the equation to y = "use x to represent y"
then plot(x,"use x to represent y")
But since that y has a square(which means y = "square root of something").
So it wont show the negative part of y.
Is there any efficient way to plot such quadratic equation?
You can try doing something like this
a = 1;
b=1;
c=1;
d=1;
e=1;
f=1;
ezplot([num2str(a),'*x.^2 +',num2str(b),' *y.^2 + ',num2str(c),'*x.*y + ',num2str(d),'*x + ',num2str(e),'*y -',num2str(f)],[-10,10,-10,10])
I am trying to plot something similar to below:
I am using Matlab. I achieved drawing contour plots. However I could not draw the discriminant. Can anyone show a sample Matlab code or give some idea to draw the discriminant?
If you know the probability density function of each of the gaussian for a given point (x,y), lets say its pdf1(x,y) and pdf2(x,y) then you can simply plot the contour line of f(x,y) := pdf1(x,y) > pdf2(x,y). So you define function f to be 1 iff pdf1(x,y)>pdf2(x,y). This way the only contour will be placed along the curve where pdf1(x,y)==pdf2(x,y) which is the decision boundary (discriminant). If you wish to define "nice" function you can do it simply by setting f(x,y) = sgn( pdf1(x,y) - pdf2(x,y) ), and plotting its contour plot will result in exact same discriminant.
Here is how I would solve this problem analytically: you equate these two discriminant functions
g1(x)=x' W1 x + w1' x + w10
g2(x)=x' W2 x + w2' x + w20
g1(x) = g2(x)
==> x' (W2 - W1) x + (w2-w1)'x + w20 - w10
then, I consider W2 - W1 to have be this matrix
W2-W1 = [a b; c d]
which then by expanding vector x=[x1 x2]', we get:
a x1^2 + (b+c) x1 x2 + d x2^2 + (w21-w11) x1 + (w22-w12) x2 + w20-w10 = 0
this is the equation of an ellipse, so you can simplify it into the form below:
(x1 - a0)^2/h + (x2-b0)^2/g = r^2
Or, you can assume that you know the range of x1 for example x1=[-2:0.1:2], and then solve the parabola