using for loop with if

1 回表示 (過去 30 日間)
Tyohoon Bay
Tyohoon Bay 2020 年 5 月 22 日
コメント済み: Tyohoon Bay 2020 年 5 月 22 日
I cannot manage this code, Iam new please help!!!
r1 = 0.103;
x1 = 1.1;
x2 = 1.13;
xm = 59.4;
v_phase = 400 / sqrt(3);
n_sync = 1500;
w_sync =2*pi*50/2;
v_th = v_phase * ( xm / sqrt(r1 (1) ^2 + (x1 + xm )^2) );
z_th = ((j* xm ) * (r1 + j* x1)) / (r1 (1) + j*( x1 + xm ));
r_th = real(z_th);
x_th = imag(z_th);
for m =1:3
if m==1
r2=0.225;
elseif m==2
r2=0.325;
else
r2=0.425;
end
Ik= v_th/(z_th+(j*x2+r2(m)));
fprintf(' Ik = %.f ' \ ', abs (Ik))
end
fprintf(' Ik = %.f ' \ ', abs (Ik))
|
Error: A MATLAB string constant is not terminated properly.

採用された回答

SayedPedram Hosseini
SayedPedram Hosseini 2020 年 5 月 22 日
you havn't defined IK, therefore abs(IK) is unrecognized
besides, in last line you have one( ' ) superfluous. It should be
fprintf(' Ik = %.f \ ', abs (Ik));
  1 件のコメント
Tyohoon Bay
Tyohoon Bay 2020 年 5 月 22 日
thanks

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

その他の回答 (1 件)

James Tursa
James Tursa 2020 年 5 月 22 日
編集済み: James Tursa 2020 年 5 月 22 日
I'm guessing you want a newline at the end?
fprintf(' Ik = %.f \n', abs (Ik))
  1 件のコメント
Tyohoon Bay
Tyohoon Bay 2020 年 5 月 22 日
thanks,

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

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by