resize and fill table
Mostra commenti meno recenti
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!
Risposta accettata
Più risposte (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 Commento
Sanley Guerrier
il 17 Lug 2023
Categorie
Scopri di più su Cell Arrays in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!