I was always very bad with matlab (I used it for the last time probably more than 10 years ago), so I cannot give you any tip regarding similarities and differences between R and matlab. But we have here a home work policy that I suggest you reading and act accordingly to it:
You should explain things and explain us more about what do you want to do...
In good will, I can tell you, that at least for what I do in R, I use ifelse
statements in limited situations. In the code you pasted, it could be used, but it would be quite obfuscated. as you would concatenate several ifelse statements inside ifelse statements.
What you are looking for, in my opinion are, if elses, much more elegant (in my weird opinion xD )
something like:
if (condition meets){
do something
} else if (another condition meets {
do other thing
} else if (another condition meets) {
do another stuff
}
You are not that far from that
cheers