필터 지우기
필터 지우기

Appending data to end of column in Table (for Loop)

조회 수: 18 (최근 30일)
MILLER BIGGELAAR
MILLER BIGGELAAR 2022년 10월 22일
댓글: MILLER BIGGELAAR 2022년 10월 22일
Hey guys,
Currently I have 14 .csv files in which I need certain values from ( a column of data ).
the values are all for the same variable and are the maximum temperatures for days in a month ( I have a range from 09/2021 - 10/2022)
What I would like is to collect data from each table into a single nx1 table.
My current for loop works correctly except that it overrides each iteration with the next.
code is as follows:
clear
clc
range = 'D10:D39';
t1 = datetime(2021,09,01);
t2 = datetime(2022,10,01);
t = t1:calmonths(1):t2;
t = convertStringsToChars(string(yyyymmdd(t)));
t = cellfun(@(S) S(1:end-2), t, 'Uniform',0);
for i = 1:length(t);
filename = convertCharsToStrings(append('IDCJDW7021.', t(i), '.csv'));
T = readtable(filename,'Range',range,'ReadVariableNames',false);
end
anythign above the for loop is working fine and besides the data overwrite problem, the for loop is operational.
Will I need to create a table prior to the for loop with the designated size?
Thanks in advance!
Miller

채택된 답변

VBBV
VBBV 2022년 10월 22일
T{i} = readtable(filename,'Range',range,'ReadVariableNames',false);
You can use cell arrays instead
  댓글 수: 1
MILLER BIGGELAAR
MILLER BIGGELAAR 2022년 10월 22일
Simple fix! how would I go about concatenating all values into a single column vector?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by