Clean data and extraction
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Sanley Guerrier
el 22 de Oct. de 2023
Comentada: Sanley Guerrier
el 22 de Oct. de 2023
Dear expert-
I am trying to fill a column and extract some specific rows from a data, I cannot figure out how to do it.
What I want to do is:
1) If row from column H = 0, replace 0 with its corresponding row value from column G.
2) If column G = column S, extract only that row + row before and row after.
Your will be very appriciated.
Thank you
4 comentarios
Dyuman Joshi
el 22 de Oct. de 2023
Yes, I understood that and provided suggestions accordingly.
I specified a flow chart to go through what you want to do, whereas @Voss was kind enough to provide you a full working solution.
Respuesta aceptada
Voss
el 22 de Oct. de 2023
T = readtable('data.xlsx');
T.Properties.VariableNames = num2cell(char(64+(1:size(T,2))));
% set H = G where H == 0
idx = T.H == 0;
T.H(idx) = T.G(idx);
% extract rows +/- 1 where G == S
idx = T.G == T.S;
idx = any([idx [false; idx(1:end-1)] [idx(2:end); false]],2);
extracted_rows = T(idx,:)
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!