str2num results
조회 수: 2 (최근 30일)
이전 댓글 표시
Here is a test, please try it. I can't explain the reason. Thanks.
>> a='sss'
a =
'sss'
>> b=str2num(a)
b =
[]
>> isnumeric(b)
ans =
logical
1
>> a='ss'
a =
'ss'
>> b=str2num(a)
b =
Empty state-space model.
>> isnumeric(b)
ans =
logical
0
>> a='ssa'
a =
'ssa'
>> b=str2num(a)
b =
[]
>> isnumeric(b)
ans =
logical
1
>>
댓글 수: 1
Geoff Hayes
2020년 2월 5일
John - I saw this link Create state-space model, convert to state-space model which may be relevant given the 'ss' string and the 'Empty state-space model' message. Perhaps, under the hood, MATLAB is taking the 'ss' string and somehow creating a state space model (since ss is the function used to create a state space model).
답변 (3개)
Steven Lord
2020년 2월 5일
From the documentation page for str2num: "In addition, str2num uses the eval function, which can cause unintended side effects when the input includes a function name. To avoid these issues, use str2double."
Neither sss nor ssa are functions in any MathWorks product.
ss is a function in Control System Toolbox.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Extraction에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!