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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by