Write a function with the following header function upper ca

Write a function with the following header: function (upper case, lower case, numbers, special] = mycell_extractor(array) where _ array is a 1 _ n cell array Each element of array is either: _ A non-empty row vector of class double _ A non-empty row vector of class char (i.e a non-empty character string). _ A non-empty cell array that follows the same format as array _ uppercase is a non-empty row vector of class char that contains all the upper case characters found in the elements of the input parameter array, in the order in which they appear in array. _ lower_case is a non-empty row vector of class char that contains all the lower case characters found in the elements of the input parameter array, in the order in which they appear in array _ numbers is a non-empty row vector of class double that contains all the elements of class double (except for NaN. -Inf. and Inf) found in the elements of the input parameter array, in the order in which they appear in array. _ special is a non-empty row vector of class double that contains all the elements of class double among NaN, -Inf. and Inf, that are found in the elements of the input parameter array, in the order in which they appear in array. Treat lower case letters from a to z as lower case characters, and any other character as upper case. You can assume that you will _nd in array: _ At least one lower case character; and 10 _ At least one upper case character; and _ At least one element of class double that is not NaN. -Inf, or Inf; and _ At least one element of class double that is one of NaN. -Inf. and Inf In other words, none of your function\'s outputs should be an empty array.

Solution

Function Code :

function [upper_case, lower_case, numbers, special]=my_cell_extractor(array)
c1=1;
c2=1;
c3=1;
c4=1;
if nargin == 0
   error(\'No input arguments were supplied. At least one is expected.\');

elseif nargin == 1
   if ~iscell(array)
       error(\'Input argument is not a cell array. A cell array is expected.\');
   end
elseif nargin > 1
   error(\'Too many input arguments supplied. Only two are allowed.\');
end

% Get the dimensions of the input cell array.
[nrows, ncols] = size(array);
temp1=[];
temp2=[];
temp3=[];
temp4=[];
% Place the cells for this column in variable \'B\'.
for i=1:ncols
if (ischar(array{1,i}))
  
if (array{1,i}==upper(array{1,i}))
temp1(c1)=char(array{1,i})
temp1(c1)=char(temp1(c1));
c1=c1+1;
elseif (array{1,i}==lower(array{1,i}))
temp2(c2)=char(array{1,i});
c2=c2+1;
end
elseif (isnumeric(array{1,i}))
  
if (strcmp(array{1,i},\'NaN\'))
temp4(c4)=\'NaN\';
c4=c4+1;
else
temp3(c3)=array{1,i};
c3=c3+1;
end
end
end
upper_case=char(temp1);
lower_case=char(temp2);
numbers=temp3;
special=NaN;
end

%% Test Code

clc;
close all;
clear all;
%% test it
[u,l,n,s]=my_cell_extractor({4,\'NaN\',6,0,\'a\',-1,\'B\'})

OUTPUT:


temp1 =

66


u =

B


l =

a


n =

4 6 0 -1


s =

NaN

>>

 Write a function with the following header: function (upper case, lower case, numbers, special] = mycell_extractor(array) where _ array is a 1 _ n cell array E
 Write a function with the following header: function (upper case, lower case, numbers, special] = mycell_extractor(array) where _ array is a 1 _ n cell array E

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site