Still trying to grasp around the basics of Matlab.
I have a function f, that takes as arguments a matrix A, and two numbers (max and delta).
I also have a function g that takes a matrix A and one number threshold and returns a matrix B, if the value of an element in A is bigger than or equal to threshold, the corresponding value in B should be 1, if it is smaller than or equal to -threshold, it should be -1, otherwise 0. The original matrix should not be changed in neither function f nor g.
I want function f to try different values for threshold in the call for g, and I want the results from each call to line up horizontally in a new matrix.
I'm not sure how to do this function f, I'm guessing the easiest way would be to create an array:
t1= [-threshold:delta:threshold];
but how do I call g for each value of the elements in the array and line them up in a new array?
function B = f(A, threshold, delta)
t1= [-threshold:delta:threshold];
%What to write here?
end
function B = g(A, threshold)
B=(A>=threshold)-(A<=-threshold);
end
If
A=[[-3:-1]' [1:3]']
Then
f(A, 2, 1)
should return the same matrix as the command [[-1 -1 0]' [0 1 1]' [-1 -1 0]' [0 1 1]']