MatLab Help on Defining New Signals

Thread Starter

tquiva

Joined Oct 19, 2010
176
I'm entirely new to MatLab, and I have no idea how to go about doing this problem.

Problem:
Consider the complex exponential signal x(t) =X*exp*(s_x*t) with the phasor X and the complex frequency s_x. Define the new signals:

a(t) = 2*x^3(t)
b(t) = 4/x(t)
c(t) = conj(x(t))
d(t) = 2*a(t) + 6*b(t)
f(t) = (d^2*x(t)) / dt^2
g(t) = d(t) + 5*f(t)

(a) Use numerical Matlab plots to investigate each of the above new signals; determine the signals that appear to be complex exponentials.



I've watched some of the demos on MatLab and read the manual, and I am quite unsure of my chosen approach to this. I would first create a new script or .m file defining these functions? And then enter them into the command window??

Could someone advanced with MatLab please give me just one example how to begin this problem?
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
I don't mind trying your suggestion, but what do you mean by test value?
Could you please give me an example?
 

Georacer

Joined Nov 25, 2009
5,182
If your Matlab package includes the symbolic math library, you could type:
Rich (BB code):
syms x t
x=exp(t) \\assume that X and x_s are 1
ezplot(x,[-5,5]) \\ispect the plot of x

syms a
a=2*x^3
ezplot(a)
\\and so on
If the first command (syms) pops an error that means you don't have the library and we 'll have to go around it. Tell me if this is the case and we 'll try something else.
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
For the first part:


Rich (BB code):
EDU>> syms x t
x=exp(t) \\assume that X and x_s are 1
ezplot(x,[-5,5]) \\ispect the plot of x
??? x=exp(t) \\assume that X and x_s are 1
              |
Error: Unexpected MATLAB operator.
And the second part:

Rich (BB code):
EDU>> syms a
a=2*x^3
ezplot(a)
\\and so on
 
a =
 
2*x^3
 
??? \\and so on
    |
Error: Unexpected MATLAB operator.
Is that what I am supposed to get?
 

Georacer

Joined Nov 25, 2009
5,182
Just remove the "\\" along with the content after it in the same line.
I used it to tell you that this is a comment, but Matlab actually uses the ";" sign to do it.
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
alright, so once I have these test values for x and s_x,
how woudl I go about declaring the functions (signals)...
such as a(t) = 2*x^3(t) ?

Do I just type in 'function' in the MatLab command window?
 

Georacer

Joined Nov 25, 2009
5,182
I 'll retype the code you have to write in order to build the functions:
Rich (BB code):
syms x t a b c d f g
x=exp(t)
a=2*x^3
b=4/x
and so on, until you declare all your symbolic functions.
You can group all that in an .m file.

Afterwards, if you want to inspect a function, you can do so by typing
Rich (BB code):
ezplot(f,[xmin, xmax])
where f is the desired function and xmin and xmax the graph limits.
 

Georacer

Joined Nov 25, 2009
5,182
You can use the command
Rich (BB code):
diff(f,n)
to differentiate the function f n times.

Do the graphs seem ok to you? Does the complex exponentials part of the question seem ok?
Tell us what you think.

The other way to generate the functions would be to create a long time table, say, from -100 to 100, maybe with more than a unit of accuracy, and apply all the above functions element-wise with the arrayfun command. That takes more time and requires you to pick a correct time table and amount of precision.

Remember: Matlab built-in help is an invaluable help.
 
Last edited:

Thread Starter

tquiva

Joined Oct 19, 2010
176
Thank you very much. I think I've got that part down now. So for a), how would I go about determining the signals (functions) that appear to be complex exponentials with the MatLab numerical plots?
 

Georacer

Joined Nov 25, 2009
5,182
The signals would be complex exponentials if the power of e was a complex number. However we assumed that s_x was a real number. You can substitute s_x for a complex number, i.e. 1+1j and run the simulations again. This time most of the signals will be complex exponentials.

A complex exponential resembles a sine wave when plotted. More info on how your professor wants to solve the exercise would be helpful.
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
Problem:
Consider the complex exponential signal x(t) =X*exp*(s_x*t) with the phasor X and the complex frequency s_x. Define the new signals:
In the code example that you gave me, why didn't you include the capital X in the equation x(t) ?
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
So I tried this:

Rich (BB code):
EDU>> syms x t a b c d f g
EDU>> s=1+1j;
EDU>> x=exp(s*t);
EDU>> a=2*x^3;
EDU>> b=4/x;
EDU>> c=conj(x);
EDU>> d=2*a+6*b;
EDU>> f=diff(x,2);
EDU>> g=d+5*f;
Then I tried to graph a, but I got an error:

Rich (BB code):
EDU>> ezplot(a,[-10, 10])
Warning: Cannot plot 2*exp(t*(3*i + 3)):  This function has no real values. 
> In ezplot>ezplot1 at 471
  In ezplot at 144
  In sym.ezplot at 56
Error in ==> ezplot>ezplot1 at 420
error(nargchk(4,6,nargin,'struct'));

??? Output argument "hp" (and maybe others) not assigned during call to
"/Applications/MATLAB_R2010aSV.app/toolbox/matlab/specgraph/ezplot.m>ezplot1".

Error in ==> ezplot at 144
    [hp,cax] = ezplot1(cax,f{1},vars,labels,args{:});

Error in ==> sym.ezplot at 56
      h = ezplot(char(f),varargin{:});
What correction do I need to make?

I noticed that if I remove the complex number s, then the plotting actually works.

When I put this into the command window:
Rich (BB code):
ezplot(a,[-10, 10])
I receive this graph:


Is this correct? And how would I be able to tell if the function is a complex exponential?
 

Attachments

Last edited:

Thread Starter

tquiva

Joined Oct 19, 2010
176
For the second part of the problem, it says:

(b) For each signal that appears to be a complex exponential, use symbolic Matlab to relate the phasor and complex frequency of the new complex exponential to those of x(t).

What exactly is 'symbolic Matlab' and how would I use it to relate X and s_x (phasor and complex frequency) ?
 

Georacer

Joined Nov 25, 2009
5,182
You cannot plot a complex number as a function of time in a 2-D plot. It just doesn't make sense. Instead use this to approach the result from its real and imaginary part
Rich (BB code):
syms t
s=(1+i)
x=exp(s*t)
ezplot(real(x))
The imaginary part will give you a similar waveform with an offset of 90 degrees. The fact that instead of a simple exponential, you get a wavy line, betrays the fact that you have a complex exponential at your hands. A complex exponential is given by the expression
\(f(t)=e^{(x+yi) \cdot t}=e^{x \cdot t} \cdot e^{i \cdot (y \cdot t)}\)
If y is greater that zero, you will end with a sine wave with increasing magnitude. It will still cross the x-axis twice in every period.

You can revise that by adding
Rich (BB code):
temp=axis
axis([temp(1), temp(2), -1, 1])
to your code, thus zooming in the y-axis.

For the second part:
From what I understand, you have to compare the phasor and frequency magnitudes of the functions in respect to the ones of x.
In other words if \(x=e^{(x+yi) \cdot t}\) and \(y=con \cdot e^{(a+bi) \cdot t}\), the phasor ratio is \(\frac{con \cdot e^{a \cdot t}}{e^{x \cdot t}}=con \cdot e^{(a-x) \cdot t}\) (not constant).
The frequency ratio is \( \frac by \) and this is constant.

Is that clear?
 
Top