MATLAB: 1- Write a MATLAB function that returns the number of entries in a vector whose value exceeds 10 and the number of entries whose values are less than 2. The function takes the vector as an argument in the function. Test your function on vector [11,

matlab function

Here is what I have so far for it:
function output=vector(n) % promt user to enter vector. n=input('Enter an array of numbers: ') count=0 if n>10 | n<2 output=1 else output=0 end count(output)
end

Best Answer

Hi,
Note: It’s not a function but if you use the function template it would be fine, the algorithm is the main thing here.
n=randi([1 100],1,10)
counter = 0;
for i = 1:length(n)
if n(i)> 10 | n(i)<2
counter = counter + 1;
end
end
counter