How do i take complex number inputs in matlab appdesigner?

3 ビュー (過去 30 日間)
Samiul Hossain
Samiul Hossain 2022 年 2 月 12 日
回答済み: Voss 2022 年 2 月 12 日
I have to take both real and complex number inputs in appdesigner. I tried using Edit FIeld (Numeric) but it wont take complex inputs. Need something to take complex or real numbersas input

回答 (1 件)

Voss
Voss 2022 年 2 月 12 日
A NumericEditField cannot be used for complex numbers. From the documentation:
MATLAB rejects the value if:
  • It cannot convert the character vector to a scalar number.
  • The value is NaN, blank, or a complex number.
  • The value is a mathematical expression, such as 1 + 2.
  • The value is less than the Limits property lower limit or greater than the upper limit.
But you can use an EditField (not Numeric), in which case the Value will be a string or character vector, which you can convert to a number using str2double() (or str2num() if you need to allow non-scalars). For example:
str = app.my_edit_field.Value; % say str is '1+1i'
num = str2double(str); % then num is 1+1i

カテゴリ

Help Center および File ExchangeString についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by