Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Substring block returns incorrect value

조회 수: 2 (최근 30일)
Scott
Scott 2018년 5월 10일
마감: MATLAB Answer Bot 2021년 8월 20일
Problem
I'm trying out the new "String" blocks available in R2018 and have found some behaviour that I can't explain. I'm trying to extract values from a string that I've created which looks like "D = (500,500,500). I've tried to do this inside a masked subsystem. Parameters for it are prefix (the symbol that indicates the start of the data I'm interested in), offset (how far after the prefix is the first character to return), num_chars (how many characters to return)
In order to get the first value I find the index of the "(" symbol using the String Find block, add an offset (of 1) to the index and then use the Substring block to get three characters from the string starting at the specified index. However sometimes this correctly returns "500" other times it returns "00,".
How I've been able to replicate the issue
If I change the value of the offset to zero it correctly returns "(50".
I then change the offset back to 1 and it correctly returns "500", result of the addition of the offset is 6 is this time.
The next time I run the simulation, it incorrectly returns "00," again. Result of the addition of the offset is now 7.
The output of the String Find block seems to change despite the string nor the substring changing.
Any ideas? Is this a bug?

답변 (1개)

Arvindhan Sayapathy
Arvindhan Sayapathy 2018년 5월 18일
I am a MathWorks staff. This is a bug and I have forwarded this feedback to the relevant team.
  댓글 수: 1
Scott
Scott 2018년 5월 21일
Thanks for reporting it.

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by