In short, I have an array that has numbers from 0 to 100 using a step of 0.01, I created a function that is supposed to output another array containing 1's and -2's. While looping on the indices of my first array if the number is smaller than 40, I insert 1 in my output array, otherwise I insert a -2. I don't know what's the problem in my code:
function [outputVector] = myOutput(inputVector)outputVector = [];for i=1 : size(inputVector) if inputVector(i) < 40 outputVector = [outputVector,1] ; else outputVector = [outputVector,-2]; endendend
Best Answer