remove the first header

조회 수: 92 (최근 30일)
SYML2nd
SYML2nd 2019년 8월 6일
편집: Jyotsna Talluri 2019년 8월 11일
Hi
I have this csv file. As you can see in the png file the first header is useless for me. I want to import a table and then remove the first row, I want to use as headerline the second row (the one that have "Time, w-vel_1, v-vel_1, u-vel_1, w-vel_1.25").
I tried to do that using the command readtable, but once I use this command it considers the first row as headerline and I don't know how to remove it and use as headerline "Time, w-vel_1, v-vel_1, u-vel_1, w-vel_1.25"
Thank you in advance

답변 (1개)

Jyotsna Talluri
Jyotsna Talluri 2019년 8월 11일
편집: Jyotsna Talluri 2019년 8월 11일
Hi,
Variables w-vel_1, v-vel_1, u-vel_1, w-vel_1.25 are not valid variable names as these include ‘-’,’.’ characters. So change your header variable names.
% reading csv file to a table without header
m=readtable('questionmatlabs.csv','ReadVariableNames',0);
t=m(2,:); %extracting the data of the second row
c=table2cell(t); %converting table to cellarray
c={'Time','w_vel_1','v_vel_1','uvel_1','w_vel_25'};
m.Properties.VariableNames=c; % setting the second row as header
m([1,2],:)=[]; % deleting first 2 rows of table

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by