Filter löschen
Filter löschen

Deleting line containing symbol.

4 Ansichten (letzte 30 Tage)
ZK
ZK am 4 Feb. 2013
Hi can You help me finish this command:
E(any(regexp(E, 'A|' , 'match' );,2),:) = [];
Deleting line in variable E(readed by textscan), containing A|.
Thank You.

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 4 Feb. 2013
Bearbeitet: Azzi Abdelmalek am 4 Feb. 2013
E={'| 00:00 | A| | A| A| A|'
'| 00:15 | 1.21 | | 1.34 | 1.42 | 1.34 |'
'| 00:30 | 1.42 | | 1.76 | 1.34 | 1.45 |'
'| 00:45 | 1.23 | | 1.34 | 1.67 | 1.23 |'}
out=cellfun(@(x) strrep(x,'A|',''),E,'un',0)
out=cellfun(@(x) strrep(x,'|',''),out,'un',0)
  6 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 4 Feb. 2013
Ok
E={'| 00:00 | A| | A| A| A|'
'| 00:15 | 1.21 | | 1.34 | 1.42 | 1.34 |'
'| 00:30 | 1.42 | | 1.76 | 1.34 | 1.45 |'
'| 00:45 | 1.23 | | 1.34 | 1.67 | 1.23 |'}
idx=find(cell2mat(cellfun(@(x) ~any(strfind(x,'A|')),E,'un',0)))
out=E(idx)
ZK
ZK am 4 Feb. 2013
Working great. Thank You for Your time, and great answer of course.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 4 Feb. 2013
E='assA|stA|'
idx=regexp(E,'A|')
E(idx+1)=[]
  4 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 4 Feb. 2013
%or
E={'assA|stA|';'azekaA|assaA|'}
for k=1:numel(E)
a=E{k}
idx=regexp(a,'A|')
a(idx+1)=[]
E{k}=a
end
ZK
ZK am 4 Feb. 2013
Bearbeitet: Azzi Abdelmalek am 4 Feb. 2013
Yes of course, sorry for that.
Example:
E<1x1 cell>
<4x1 cell>
| 00:00 | A| | A| A| A|
| 00:15 | 1.21 | | 1.34 | 1.42 | 1.34 |
| 00:30 | 1.42 | | 1.76 | 1.34 | 1.45 |
| 00:45 | 1.23 | | 1.34 | 1.67 | 1.23 |

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Import and Export finden Sie in Help 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