Cell-Array operation in large Cell-Array (Vectorization?)

Hello,
I have a large cell-array containing 150k rows and 8 columns.
It's a mix of numbers and strings.
The end of the string in column 7 always is equal to the string in column 8 (e.g.: A{1,7} = 'hello test'; A{1,8} = 'test').
I want to "subtract" the strings in column 8 from column 7, as well as the space characters (varying length) in front of 'test' in the example above (of course for all elements).
It should look like this:
A{1,7} = 'hello'; A{1,8} = 'test'.
Is there an efficient way to do this without using a for-loop?
Thank you very much in advance.

回答 (1 件)

KSSV
KSSV 2022 年 1 月 24 日

1 投票

Read about erase.
C1 = {'Hello man'; 'Hello boss' ; 'Hello kid'} ;
C2 = {'man'; 'boss' ; 'kid'} ;
C = erase(C1,C2)
C = 3×1 cell array
{'Hello '} {'Hello '} {'Hello '}

2 件のコメント

Valentin Pichlmaier
Valentin Pichlmaier 2022 年 1 月 24 日
with your method, there was an error because the array was too big...
strrep worked for me!
Thank you.
KSSV
KSSV 2022 年 1 月 24 日
What was the error?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeVariables についてさらに検索

製品

リリース

R2021b

質問済み:

2022 年 1 月 24 日

コメント済み:

2022 年 1 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by