How to better utilize 'input'?

3 ビュー (過去 30 日間)
Chad Pilbeam
Chad Pilbeam 2018 年 3 月 25 日
回答済み: Walter Roberson 2018 年 3 月 25 日
I am trying to create a program that will take user inputs for different force vectors and weights and the like. I want to make the code give an error message, and re-prompt the user to input an integer if the user inputs a character instead, without the program crashing and MatLab errors being displayed. Any help on how to do this?

採用された回答

Star Strider
Star Strider 2018 年 3 月 25 日
I prefer the inputdlg (link) function. It saves the input values to a cell array, so you can then convert and check them yourself before looping back if a returned value is not what you want. If you are requesting multiple inputs, you can even save the correct inputs as the default values so the user doesn’t have to re-enter them.
  2 件のコメント
Chad Pilbeam
Chad Pilbeam 2018 年 3 月 25 日
Thanks!
Star Strider
Star Strider 2018 年 3 月 25 日
My pleasure!

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 3 月 25 日

カテゴリ

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