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!