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 件のコメント

Samuel Anderson
Samuel Anderson 2018 年 1 月 30 日
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 ExchangeCreating 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