This question is closed. Reopen it to edit or answer.
variable changes when reading it from user gui
2 views (last 30 days)
Show older comments
Mustafa Al-Nasser on 25 Aug 2020
Closed: MATLAB Answer Bot on 20 Aug 2021
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
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.
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!