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.
댓글 수: 0
채택된 답변
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 Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!