Plotting values from a double array based on information from a cell array
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Justin Rosenthal
am 24 Jan. 2022
Kommentiert: Justin Rosenthal
am 24 Jan. 2022
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.
0 Kommentare
Akzeptierte Antwort
David Hill
am 24 Jan. 2022
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays 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!