Write a function with the following header function npositiv
Solution
% matlab code
function[n_positive, n_negative, n_zero, n_special] = my_array_metrics_num(array)
 n_positive = 0;
 n_negative = 0;
 n_zero = 0;
 n_special = 0;
 [n,m] = size(array);
 for i=1:n
 for j=1:m
 if array(i,j) == Inf
 n_positive = n_positive + 1;
 n_special = n_special + 1;
 elseif array(i,j) == -Inf
 n_negative = n_negative + 1;
 n_special = n_special + 1;
 elseif array(i,j) == NaN
 n_special = n_special + 1;
 elseif array(i,j) < 0
 n_negative = n_negative + 1;
 elseif array(i,j) > 0
 n_positive = n_positive + 1;
 elseif array(i,j) == 0
 n_zero = n_zero + 1;
   
 end
 end
 end
 end
array = [5, 0 , 0, Inf, -1 , 7];
 [n_positive, n_negative, n_zero, n_special] = my_array_metrics_num(array);
 disp(\"n_positive = \");
 disp(n_positive);
 disp(\"n_negative = \");
 disp(n_negative);
 disp(\"n_zero = \");
 disp(n_zero);
 disp(\"n_special = \");
 disp(n_special);
%{
 output:
n_positive =
 3
 n_negative =
 1
 n_zero =
 2
 n_special =
 1
%}
![Write a function with the following header: function [n_positive, n_negative, n_zero, n special] = my array metrics num (array) where: array is an arbitrary n   Write a function with the following header: function [n_positive, n_negative, n_zero, n special] = my array metrics num (array) where: array is an arbitrary n](/WebImages/38/write-a-function-with-the-following-header-function-npositiv-1113830-1761591204-0.webp)
![Write a function with the following header: function [n_positive, n_negative, n_zero, n special] = my array metrics num (array) where: array is an arbitrary n   Write a function with the following header: function [n_positive, n_negative, n_zero, n special] = my array metrics num (array) where: array is an arbitrary n](/WebImages/38/write-a-function-with-the-following-header-function-npositiv-1113830-1761591204-1.webp)
