From: us on
"Meedo " <mohabedalgani(a)yahoo.com> wrote in message <hv204k$huk$1(a)fred.mathworks.com>...
> Hi,
>
> How can i replace a char by another one using its index.
>
> e.g.
>
> s='matlab'
> s1='a';
> s2='A';
>
> How to replace only the first a (index 2 in the s string) with A, to be
>
> ans= mAtlab
>
> Does Matlab provides this kind of string indexing??
>
> i appreciate any comments..
>
> Mohammad

one of the many other solutions

s='matlab';
r=regexprep(s,'a','A','once')
% r = mAtlab

us