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);

 채택된 답변

James Tursa
James Tursa 2018년 1월 29일

1 개 추천

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);

추가 답변 (1개)

Jan
Jan 2018년 1월 29일

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

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.
Jan
Jan 2018년 1월 30일
@Samual: See: help hold

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2018년 1월 29일

댓글:

Jan
2018년 1월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by