b=regexpre​p(b,'^','.​^','all'); doesn't works.

I want to replace ,/,^ to .,./,.^
my code:
syms t;
a='t^3+t*t+t^2/t';
b=a;
b=regexprep(b,'*','.*','all');
b=regexprep(b,'/','./','all');
b=regexprep(b,'^','.^','all');
Result I want:
a=t^3+t*t+t^2/t
b=t.^3+t.*t+t.^2./t
Real result:
a=t^3+t*t+t^2/t
b=t^3+t.*t+t^2./t
I think " b=regexprep(b,'^','.^','all');" doesn't works.
How can I fix this problem?

 Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 8 Jul. 2013
Bearbeitet: Andrei Bobrov am 8 Jul. 2013

0 Stimmen

syms t;
a=t^3+t*t+t^2/t;
b = vectorize(a);

Weitere Antworten (2)

Jan
Jan am 8 Jul. 2013

0 Stimmen

STRREP is faster than REGEXPREP:
b = strrep(b, '^', '.^');

Kategorien

Mehr zu MATLAB Coder finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by