Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
uint8, characters

Subject: uint8, characters

From: John

Date: 7 Feb, 2014 16:58:07

Message: 1 of 2

So I'm given an array of names of countries, and I am supposed to find how many countries in that array start with the letter U. So what I did was uint8 command to find the individual integer values of all the characters in the array. Then I used the same command to find the specific value for U. My question is how do I count the number of integer values= U from the entire array. Thanks

Subject: uint8, characters

From: James Tursa

Date: 7 Feb, 2014 18:50:10

Message: 2 of 2

"John" wrote in message <ld33av$h5k$1@newscl01ah.mathworks.com>...
> So I'm given an array of names of countries, and I am supposed to find how many countries in that array start with the letter U. So what I did was uint8 command to find the individual integer values of all the characters in the array. Then I used the same command to find the specific value for U. My question is how do I count the number of integer values= U from the entire array. Thanks

I would suggest you show us your code. Not sure why you would convert to uint8 first ... why not do the comparison as char instead? Code for doing the comparison will depend on how the names are represented. E.g., if it is an array of strings then something like names(:,1)=='U' would give you a logical result with the 1's being the rows where the name started with 'U'. Then you could use the sum function to count the total.

James Tursa

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us