resize and fill table
Afficher commentaires plus anciens
Hello, How can I resize the table, I mean fill out missing values in column A so that the pattern repeat itself. For example, 0 1 2 3 0 1 2 3.........
And then replace the corresponding rows to these values by NaN in column B and C. After resizind it, the table will have 97 rows it currently has 86 rows.
Thank you!
Réponse acceptée
Plus de réponses (1)
Does this work for you?
data = readmatrix('file.xlsx');
% Note: sometimes 0's are missing from colum 1 for some reason.
% Is this the way it's supposed to be???
[rows, columns] = size(data)
finalRow = 97;
data(end : finalRow, 2:3) = nan;
% Fill up tail of column 1 with 0;1;2;3;0;1;2;3; etc.
for row = rows+1 : finalRow
data(row, 1) = mod(row+2, 4);
end
% Optional: Convert from array to table
t = table(data(:, 1), data(:, 2), data(:, 3), 'VariableNames', {'QHR', 'A', 'B'})
1 commentaire
Sanley Guerrier
le 17 Juil 2023
Catégories
En savoir plus sur Cell Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!