String input saves as character.

14 ビュー (過去 30 日間)
John Lemos
John Lemos 2020 年 10 月 3 日
回答済み: Ameer Hamza 2020 年 10 月 3 日
month_num = input('\nPlease enter the number of the month you would like to look at, i.e. 1 for January, 2 for February, etc.:\n', 's');
month_num = str2dbl(month_num);
I'm trying to save a month number as a string and then convert it to a double (class requirement, not my choice) but everytime I run the code I get the following error
Undefined function 'str2dbl' for input arguments of type 'char'.
I've tried putting string(input('')) and month_num = string(month_num); neither of which have changed the outcome.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 3 日
The correct function name is str2double(), not str2dbl().https://www.mathworks.com/help/releases/R2020b/matlab/ref/str2double.html

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by