I have a cell array that contains the following lines:
'0,31:1.03 SPEED MEASURED 1 [rpm]'
'0,31:1.04 MOTOR SPEED [rpm]'
'0,31:1.08 MOTOR TORQUE [%]'
'0,31:25.04 TORQUE REF B [%]'
I want to use them as titles for figures, but without the numbers preceding the text. For a figure that plots the measured speed, for example, I would want to have a title like this: SPEED MEASURED 1 [rpm]. How can I go about doing this?

 Akzeptierte Antwort

Stephen23
Stephen23 am 13 Jun. 2019
Bearbeitet: Stephen23 am 13 Jun. 2019

2 Stimmen

Simpler with regexprep:
>> D = regexprep(C,'^\S+\s*','')
D =
'SPEED MEASURED 1 [rpm]'
'MOTOR SPEED [rpm]'
'MOTOR TORQUE [%]'
'TORQUE REF B [%]'

1 Kommentar

Heidi Mäkitalo
Heidi Mäkitalo am 13 Jun. 2019
Thanks! I actually didn't know about this function, I've only heard of regexp before. Works well & looks neat!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Andrei Bobrov
Andrei Bobrov am 13 Jun. 2019

1 Stimme

a = {'0,31:1.03 SPEED MEASURED 1 [rpm]'
'0,31:1.04 MOTOR SPEED [rpm]'
'0,31:1.08 MOTOR TORQUE [%]'
'0,31:25.04 TORQUE REF B [%]'};
regexp(a,'(?<=\d\.\d{2}\s+).*','match','once')

Kategorien

Mehr zu Specialized Power Systems 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