Help with a phasor diagram

15 ビュー (過去 30 日間)
Brian Hoblin
Brian Hoblin 2017 年 1 月 28 日
コメント済み: Star Strider 2017 年 1 月 28 日
I'm trying to make a phasor diagram for a lab report. I'm really new to MATLAB and this is the first time I've tried this. Our textbook has a MATLAB code that is supposed to make a phasor diagram but I keep getting an error message that I can't seem to resolve, "Expression or statement is incorrect--possibly unbalanced (, {, or [.". The commented lines are what I need to run and the uncommented lines are from my textbook. The parenthesis and brackets are balanced so I'm not sure why I'm getting this message. Could someone please advise me on this?
% V1=1.716924368*exp(-j*80.1137631*pi/180);
% V2=9.8515059*exp(j*-9.8862369*pi/180);
V1=10*exp(-j*45*pi/180)
V2=5*exp(j*30*pi/180)
V=V1+V2
MagV=abs(V);
PhaseV=angle(V);
PhaseVDeg=180*PhaseV/pi;
disp(['V=',num2str(MagV,'%3.4g'),...
exp(',num2str(PhaseVDeg,'%3.4g'),'j)'])

採用された回答

Star Strider
Star Strider 2017 年 1 月 28 日
The disp call is causing the problem.
See if this does what you want:
fprintf(1, '\n\tV = %3.4g Phase = %3.4g°\n', MagV, PhaseVDeg)
It is best to use fprintf or sprintf when you want formatted output of any sort, and if the output includes different classes of variables.
  2 件のコメント
Brian Hoblin
Brian Hoblin 2017 年 1 月 28 日
Thank you
Star Strider
Star Strider 2017 年 1 月 28 日
My pleasure.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCall MATLAB from .NET についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by