Fixing matrix dimensions to match

I'm attempting to plot Pone and Ptwo(P standing for Power), vs. the AngleDif between the two sources. The program doesn't like that my matrix dimensions don't agree on the line Pone = Eone*conj(I). I don't understand how to fix this because the only matrix I'm using is the only to increment the angle theta from -30 to 30. I have very little experience using Matlab if that helps to know. I know that the inner dimensions of two matrices must match to multiply, but I'm having trouble visualizing the process here.
t = 1;
theta = (-30:5:30);
w = 120 * pi;
Eone = (100/sqrt(2))*cosd(theta)+(100/sqrt(2))*1i*sind(theta);
Etwo = (100/sqrt(2))*cosd(30)+(100/sqrt(2))*1i*sind(30);
z = 2 + 1i*5;
I = (Eone - Etwo)/(z);
Pone = Eone*conj(I);
Ptwo = Etwo*conj(I);
Ploss = I*z*z;
AngleDif = 30 - theta;
plot(Pone, Ploss, AngleDif);

 Accepted Answer

Use the element-wise operator .* (with the initial dot) instead of the matrix multiply operator * (without the dot). E.g.,
Pone = Eone .* conj(I);
Ptwo = Etwo .* conj(I);

More Answers (1)

The computations work, when you apply the elementwise multiplication with the .* operator instead of the matrix multiplication *
Pone = Eone .* conj(I);
Ptwo = Etwo .* conj(I);
But then the plotting fails:
Error using plot
Data must be a single matrix Y or a list of pairs X,Y.
Maybe you want:
plot3(Pone, Ploss, AngleDif);
but this ignores the imaginary part and show a corresponding warning also.

2 Comments

The plot3 does work, however I'm trying to plot two lines vs AngleDif, and I am ignoring the imaginary part for the graph so that isn't a problem. I think I should use
plot(Pone, AngleDif);
plot(Ploss, AngleDif);
but I want to put them on the same graph, so I'm not entirely sure.
@Samual: See: help hold

Sign in to comment.

Categories

Asked:

on 29 Jan 2018

Commented:

Jan
on 30 Jan 2018

Community Treasure Hunt

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

Start Hunting!