How do i take complex number inputs in matlab appdesigner?
Show older comments
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
Answers (1)
Voss
on 12 Feb 2022
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
Categories
Find more on String 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!