How can I get MATLAB to return Alpha1=4

Write a single MATLAB statement that will accomplish the stated purpose. Assume a text string TS1 has already been defined. Place the numeric index of the first alphabetic character in TS1 into Alpha1. Example: TS1='%@3Gb6' returns Alpha1=4.

2 Comments

That link is a link to a similar question, but it is not the same question

Answers (1)

This will work:
TS1='%@3Gb6';
Alpha1 = regexp(TS1, '[A-Za-z]')
Alpha1 =
4

This question is closed.

Asked:

on 21 Jan 2016

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!