MATLAB is changing variables when I do not want it to.

Posted by WVUstudent on Stack Overflow See other posts from Stack Overflow or by WVUstudent
Published on 2010-04-27T02:14:46Z Indexed on 2010/04/27 2:23 UTC
Read the original article Hit count: 320

Filed under:
|
|
|
|

Here is my problem in a small bit of code used as an example,
trial(0)

function [] = trial(test)

disp(test)

if(test == 1)
disp('test is one')
test = 0;
end
disp(test)

Matlab prints out this:

0
'test is one'
0

This is not my real code, there are over 500 lines of it, but this is a section of my code where the problem has risen. I have used the search function to see if I have been incrementing any variables anywhere, and have put in over 2 hours trying to see why MATLAB is changing my variables when I don't want it to.

© Stack Overflow or respective owner

Related posts about variables

Related posts about error