From: Derek on
I'm a noob when it comes to MATLAB, I'm in my first MATLAB course in my college career. I am completely stuck in this problem and don't even know where to begin. Can someone help me out?

Using switch case, if else blocks and for loops:
Write a function which takes as input a series of words(a line). Splits the line into words and appends an/a to each word appropriately. Write two functions (functionV1 and functionV2), one using if else block and the other using switch case block.
Note: You can use for loop to iterate from 1:length(input).
Eg:
Input: cat dog apple mango aeroplane Angel
Ouput:
functionV1:Using if else block
A cat
A dog
An apple
A mango
An aeroplane
An Angel
FunctionV2: Using switch case block
A cat
A dog
An apple
A mango
An aeroplane
An Angel
From: Nathan on
On May 25, 4:30 pm, "Derek " <postle...(a)osu.edu> wrote:
> I'm a noob when it comes to MATLAB, I'm in my first MATLAB course in my college career. I am completely stuck in this problem and don't even know where to begin. Can someone help me out?
>
> Using switch case, if else blocks and for loops:
> Write a function which takes as input a series of words(a line). Splits the line into words and appends an/a to each word appropriately. Write two functions (functionV1 and functionV2), one using if else block and the other using switch case block.
> Note: You can use for loop to iterate from 1:length(input).
> Eg:
> Input: cat dog apple mango aeroplane Angel
> Ouput:
> functionV1:Using if else block
> A cat
> A dog
> An apple
> A mango
> An aeroplane
> An Angel
> FunctionV2: Using switch case block
> A cat
> A dog
> An apple
> A mango
> An aeroplane
> An Angel

And what have you attempted so far to complete this task?

Have you read the documentation on if/else/switch/for?

Do you know the rules of English that determine whether a noun
receives "a" or "an"?

-Nathan
From: Derek on
Yes, I'm good with if/else and switch case, a little iffy on for loops but have the basic premise. I think the biggest obstacle for me in this is defining where a space is, and having the input as a string, not numbers, because most function files we've done have been with numbers. Would you just put single quotes around your input variable?
From: Walter Roberson on
Nathan wrote:

> Do you know the rules of English that determine whether a noun
> receives "a" or "an"?

Unfortunately, the rules are based upon pronunciation rather than on spelling:
a union, an umpire, a hint, an herbal tea. And pronunciation can be regional...
From: Steven Lord on

"Derek " <postle.18(a)osu.edu> wrote in message
news:hthnut$ji8$1(a)fred.mathworks.com...
> Yes, I'm good with if/else and switch case, a little iffy on for loops but
> have the basic premise. I think the biggest obstacle for me in this is
> defining where a space is, and having the input as a string, not numbers,
> because most function files we've done have been with numbers. Would you
> just put single quotes around your input variable?

If you go to http://www.mathworks.com and search for the word "string" using
the search box in the upper-right corner, you should see a number of "Best
Bets" on the results page. The first two you should find particularly
informative, especially the "See Also" section of the second.

If that doesn't give you enough information to complete your assignment,
post what you've got to the newsgroup and indicate where you're stuck and
you may receive some more targeted help.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com.