MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayTo resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Asked by ZK on 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.

*No products are associated with this question.*

Answer by Azzi Abdelmalek on 4 Feb 2013

Edited by Azzi Abdelmalek on 4 Feb 2013

Accepted answer

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)

Show 3 older comments

ZK on 4 Feb 2013

No I would like to delete whole line so the output should look like this:

E={'| 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 |'}

Azzi Abdelmalek on 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)

Answer by Azzi Abdelmalek on 4 Feb 2013

E='assA|stA|' idx=regexp(E,'A|') E(idx+1)=[]

Show 1 older comment

Azzi Abdelmalek on 4 Feb 2013

E={'assA|stA|'} E=E{1} idx=regexp(E,'A|') E(idx+1)=[]

Can you post a sample of your data?

Azzi Abdelmalek on 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

## 0 Comments