cellParse - index = 1 char = 0 vec = 0 bool = 0 D = {} x =...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 %%PROBLEM 7%% % Write a function named cellParse that takes in a cell array with each % element being either a string (character array), or a vector % (containing numbers), or a boolean value (logical array of length 1). % Your function should return the following in the following order: % - the number of strings % - the number of vectors % - the number of boolean values % - a cell array of all the strings in alphabetical order % - the average length of all the vectors % - true if all the boolean values are true, false otherwise % % Note: Type 'help cell/sort.m' at the command line to get more % information about sorting strings. % function [numStr numVec numBool alpha avgLen allTrue] = cellParse(ca)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: index = 1 char = 0 vec = 0 bool = 0 D = {} x = 1 A = y = 1 B = 0 while index <= length(ca) if ischar(ca{index}) == true char = char + 1 alpha{x} = ca{index} x = x + 1 elseif isnumeric(ca{index}) == true vec = vec + 1 A(y) = length(ca{index}) y = y + 1 elseif islogical(ca{index}) == true bool = bool + 1 if islogical(ca{index}) == true & ca{index} == true B = B + 1 elseif ischar(ca{index}) == true D{x} = ca{index} x = x + 1 end index = index + 1 end numStr = char numVec = vec numBool = bool alpha = D avgLen = sum(A)/length(A) if B == bool allTrue = true Sheet1 Page 2 else allTrue = false end end end...
View Full Document

This note was uploaded on 07/06/2009 for the course CS 1371 taught by Professor Stallworth during the Fall '08 term at Georgia Tech.

Page1 / 2

cellParse - index = 1 char = 0 vec = 0 bool = 0 D = {} x =...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online