Why i am getting blank graph?How can i solve this issue? - matlab

I am trying to plot symbolic variable in MATLAB, for which I have used the same strategy that is available in an answer to a similar question.
This is my code, which outputs a blank graph:
syms t w
x=exp(-t^2)
h=exp(-t)*heaviside(t)+exp(t)*heaviside(-t)
X=fourier(x,w);
H=fourier(h,w);
right=ifourier( rewrite(X*H, 'exp'),t)
fplot(right,[0 8])
How can I make the graph appear?

The problem is that MATLAB ifourier function cannot compute the inverse Fourier transform of the product X*H.
Check that X*H returns:
X*H
Rewriting the expression does not change it at all:
rewrite(X*H, 'exp')
Either way, when computing the inverse Fourier transform:
right=ifourier( X*H,t)
Documentation on the ifourier function states that:
If ifourier cannot transform the input, then it returns an unevaluated
call to fourier.
Since it cannot evaluate explicitly the function, it cannot plot it.

Related

plotting ilaplace output MATLAB

I'm trying to plot the transfer function in time domain - h,
when I run the following code I get an error:
syms s;
H=((1+2*s)*1.943)/(s*(s^2)*(1+0.15*s)+((1+2*s)*1.943));
h = ilaplace(H);
ezplot(h);
I read the help on ilaplace and understood it returns a sym function.
what am I missing?
I tried to look up on the internet and I didn't find an example that perform what I want without errors.
if it is relevant I'm using 7.12.0 (R2011a)
thanks
If you look at the expression for h, I bet you'll find it's not a straightforward expression of t, and it's not something that can be plotted by MATLAB due to the complexity of the equation. You might want to try substituting some numerical values of t with subs to get the corresponding values of h, which you could then plot using the plot command, but I don't know if this will work owing to the complexity of the inverse Laplace transform expression.

How to differentiate a function w.r.t another symbolic function in MATLAB?

Using the code,
syms x(t)
y=x^2
diff(y,t)
diff(y,x)
I get the following error:
2*D(x)(t)*x(t)
Error using sym/diff (line 26)
All arguments, except for the first one, must not be symbolic functions.
Is there a way to tackle this? Thanks for your time.
I dont know much about the Symbolic Math Toolbox, but taking a derivative wrt to a function does not seem to be supported (at least in a direct fashion) for diff.
You can substitute a variable, compute a derivative, and substitute the function back. Like so:
syms z
subs(diff(subs(y,x,z),z),z,x)
ans(t) = 2*x(t)

how to get the area of a region using matlab

I want to plot some equations and inequalities like x>=50, y>=0,4x-5y>=8,x=40,x=60,y=25, y=45 in matlab and want to get the area produced by intersecting these equations and inequalities. Is it possible using matlab? If yes can someone provide me some manual? If not, is there some other software that can do this?
Integrals would work for your purposes, provided you know the points at which the curves intersect (something Matlab is also able to compute). Take a look at the documentation on the integral function.
q = integral(fun,xmin,xmax) approximates the integral of function fun
from xmin to xmax using global adaptive quadrature and default error
tolerances.
EDIT: As an additional resource, take a look at the code provided by user Grzegorz Konz on the Mathworks blog.
EDIT #2: I'm not familiar with any Matlab functions that'll take a vector of functions and return the points of intersection (if any) between all the curves. Users have produced functions that return the set of intersection points between two curves. You could run this function for each pair of equations in your list and use a function like polyarea to compute the area of the enclosed region if the curves are all straight lines.

how to find a command in MATLAB

I have a problem:
I use lookfor to find a function or a command in MATLAB, but
Many times lookfor gives some results but when I use help for learning how to use, I see this statament:
No matches found.
What is the problem, If I use the newer version of MATLAB, this problem is solved or not?
This is supposed to happen because these two commands are different!
The lookfor command allows you to search for functions based on a keyword. It searches through the first line of help text, which is known as the H1 line, for each MATLAB function, and returns the H1 lines containing a specified keyword. For example, MATLAB does not have a function named inverse. So the response from
help inverse
is
inverse.m not found.
But
lookfor inverse
finds over a dozen matches. Depending on which toolboxes you have installed, you will find entries like
INVHILB Inverse Hilbert matrix.
ACOSH Inverse hyperbolic cosine.
ERFINV Inverse of the error function.
INV Matrix inverse.
PINV Pseudoinverse.
IFFT Inverse discrete Fourier transform.
IFFT2 Two-dimensional inverse discrete Fourier transform.
ICCEPS Inverse complex cepstrum.
IDCT Inverse discrete cosine transform.
To learn on, check out http://www.thphys.may.ie/CompPhysics/matlab/help/techdoc/basics/getting6.html.

MATLAB: Plot integral using quad/quadl

I would like to know if anybody knows how I can plot an integral calculated using quad/quadl, or if this is possible.
I read that I can set the trace parameter to be non-zero, and this results in the information of each iteration being provided, but I'm not sure how and if I can use the information to plot an integral.
Thanks.
quad and quadl do not compute an integral function anyway, i.e., an integral as a function of the parameter. And since tools like this work iteratively, refining their estimate until it satisfies a tolerance on the global value, they are not easily made to produce the plot you desire.
You can do what you desire by using a differential equation solver to generate the solution, ode45 for example.