Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
variable changes when reading it from user gui
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
I'm writing a software that needs to read some data from a code file, pass it to a user window where the user can change them, then read them back and do some calculations to present an output.
My process goes as follows:
However, the output is not what was expected based on the inputs, so i changed my code so that code file B pass the varables diretly to the function without going through the user window, so it is something like this:
output B was the correct output (i.e. the expected one based on the variables), so when i ran the first program i enter the same variables that was based on the second one, logically speaking, the output of both programs should be the same, they both have the same inputs and same functions, however output A does not equal to output B.
I tried to compare the variables when reading them directly from the previous file and when reading them after going through the gui, when i print them i can see they are the same, but when i use a function like isequal or directly using == the output is 0 (it says they are different), i also compared the size and the type of variables and it is all the same (Visually) but passing them to isequal function says they are differnt.
i concluded that there is some change made when i read them from the user gui, but this change is invisible to me, so what would be the solution to such problem?
Thank you all
댓글 수: 0
답변 (1개)
Image Analyst
2020년 8월 25일
Try using ismembertol() instead of isequal or ==.
Are you getting the variables directly, or pulling them from a static text label or edit text box? If you go through a text control on the GUI, then make sure you're using num2str() or sprintf(), and str2double() because the contents of text controls are strings, not numbers.
댓글 수: 2
Image Analyst
2020년 8월 25일
Can't really do much without the code. So I'd just suggest normal debugging:
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!