フィルターのクリア

Plotting values from a double array based on information from a cell array

1 回表示 (過去 30 日間)
Hello,
I have created a 13 x 2 cell array that has time values in the first column and keywords in the second column. It takes the form below.
'28979.015' 'hold'
'39780.015' 'hold-end'
'39910.015' 'hold'
'49108.015' 'max-pressure-evac 60.0'
'50711.015' 'hold-end'
'50841.015' 'hold'
'58642.015' 'hold-end'
'58772.015' 'hold'
'65837.015' 'max-pressure-evac 60.0'
'65973.015' 'hold-end'
'66103.015' 'hold'
'72410.015' 'max-pressure-evac 60.0'
'73304.015' 'hold-end'
I would like to add a row underneath every 'max-pressure-evac 60.0' where in the first column a constant of 61 is added to the previous value and the second column takes on the name 'evac-end'. For example:
'49108.015' 'max-pressure-evac 60.0'
should become:
'49108.015' 'max-pressure-evac 60.0'
'49169.015' 'evac-end'
Any advice on how this can be accomplished would be greatly appreciated. Thank you in advance.

採用された回答

David Hill
David Hill 2022 年 1 月 24 日
a=strcmp(yourCell(:,2),'max-pressure-evac 60.0');
f=find(a)';
f=f+(0:numel(f)-1);
for k=f
yourCell(k+1:end+1,:)=yourCell(k:end,:);
yourCell{k+1,1}=num2str(str2double(yourCell{k+1,1})+60);
yourCell{k+1,2}='evac-end';
end
  1 件のコメント
Justin Rosenthal
Justin Rosenthal 2022 年 1 月 24 日
Thank you so much for your help. This worked perfectly!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by