フィルターのクリア

How to create a custom function to output user variables?

1 回表示 (過去 30 日間)
William Edwards
William Edwards 2017 年 10 月 22 日
コメント済み: William Edwards 2017 年 10 月 22 日
I want to create a function named result() that I can use to print to the screen:
fprintf('\n*** Summary Data for Scenario:\n')
fprintf('%30s%12d\t%s\n', 'Runway Length:', runway, 'ft');
fprintf('%30s%12.1f\t%s\n', 'Rotation Speed:', rotate, 'knots');
where 'runway' and 'rotate' are user inputs from the rest of my code.
I tried:
function result()
fprintf('\n*** Summary Data for Scenario:\n')
fprintf('%30s%12d\t%s\n', 'Runway Length:', runway, 'ft');
fprintf('%30s%12.1f\t%s\n', 'Rotation Speed:', rotate, 'knots');
end
I want this in my code because the full result() function is (or would be) about 6 lines long and will be used multiple times.
  1 件のコメント
Stephen23
Stephen23 2017 年 10 月 22 日
編集済み: Stephen23 2017 年 10 月 22 日
@William Edwards: what exactly is your question? What are you trying to do? The function that you show us does not output any variables, so it is not clear what relation the title has to the body of your question.

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

採用された回答

Walter Roberson
Walter Roberson 2017 年 10 月 22 日
function result(runway, rotate)
fprintf('\n*** Summary Data for Scenario:\n')
fprintf('%30s%12d\t%s\n', 'Runway Length:', runway, 'ft');
fprintf('%30s%12.1f\t%s\n', 'Rotation Speed:', rotate, 'knots');
end
  1 件のコメント
William Edwards
William Edwards 2017 年 10 月 22 日
Ah yeah that's a simple solution, thank you! I should probably stop working with Matlab at 1 in the morning.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by