how to fprintf and disp on the same line

48 ビュー (過去 30 日間)
fawzeya bin tamim
fawzeya bin tamim 2020 年 11 月 23 日
コメント済み: fawzeya bin tamim 2020 年 11 月 23 日
i want this code to display 3 things on the same line but instead, i get this:
The number of capacitance should be 2
, i.e., 1/2 numbers of inductors
fprintf('The number of capacitance should be'); disp((length(inductance))/2); fprintf(', i.e., 1/2 numbers of inductors\n');

採用された回答

Nora Khaled
Nora Khaled 2020 年 11 月 23 日
disp always starts new line afterward.
you should only use fprintf and '\n' if you want to end the line
fprintf('The number of capacitance should be %f , i.e., 1/2 numbers of inductors\n',(length(inductance))/2)
use either %f or %d if the number is integer or float
  1 件のコメント
fawzeya bin tamim
fawzeya bin tamim 2020 年 11 月 23 日
thank you so much! it worked

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

その他の回答 (0 件)

カテゴリ

Find more on Workspace Variables and MAT-Files in Help Center and File Exchange

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by