I keep getting input error

2 ビュー (過去 30 日間)
Jorge Rodriguez
Jorge Rodriguez 2020 年 9 月 26 日
コメント済み: Jorge Rodriguez 2020 年 9 月 27 日
%r is r1 33 r2 47 = 80
% xl1 is 60 ohms xl 2 is 30 = 90
%z = sqrt(r^2 + xl^2)
%theta = atan2d(xl/r)
%ohms law i = v / z
v = input('volts:');
r = input ('resistance:');
i = current;
xl = input ('impedance:');
theta = atan2d (xl/r);
z = sqrt(r^2 + xl^2);
i = v / z;
disp ([' current is ' num2str(i) ' impedance is ' num2str(xl)']);

回答 (1 件)

KSSV
KSSV 2020 年 9 月 26 日
編集済み: KSSV 2020 年 9 月 26 日
You have to use Ohm's law instead of the unknown variable current.
Use fprintf instead disp.
%r is r1 33 r2 47 = 80
% xl1 is 60 ohms xl 2 is 30 = 90
%z = sqrt(r^2 + xl^2)
%theta = atan2d(xl/r)
%ohms law i = v / z
v = input('volts:');
r = input ('resistance:');
i = v/r ;
xl = input ('impedance:');
theta = atan(xl/r);
z = sqrt(r^2 + xl^2);
i = v / z;
fprintf ('current is: %f, impedance is %f\n', i,xl);
  3 件のコメント
KSSV
KSSV 2020 年 9 月 27 日
Read about atand.
Jorge Rodriguez
Jorge Rodriguez 2020 年 9 月 27 日
Already did. thanks

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

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by