MATLAB producing ans but wont upload variable, extremely strange behavior
2 views (last 30 days)
I am doing nothing special here but vectorizing an array
When i do something like the below code below matlab is going off, and producing an "ans" on the screen that has the correct values in it.
However, it is creating a completely empty variable called "test" despite the fact that i am setting that command to the variable test.
So i get the correct "ans" on the screen and an empty variable called test
What is going on here? I can click on "ans" in the workspace and see everything that should be there but test will be a variable of the same size but empty.
test = test1(1,1);test2(1,2)
Image Analyst on 31 Jul 2021
Edited: Image Analyst on 31 Jul 2021
Did you forget to enclose the vectors in brackets to form a matrix. See this:
test1 = rand(1,2);
test2 = rand(1,2);
test = test1(1,1); test2(1,2) % Two separate lines of code on the same line
test = [test1(1,1); test2(1,2)] % one line of code to stack the vectors on top of each other in a new matrix.
Did that produce a forehead-slapping moment?