I want to make a table with single array

조회 수: 1 (최근 30일)
Valerio Gianforte
Valerio Gianforte 2020년 3월 4일
답변: Steven Lord 2020년 3월 4일
Hi everyone,
I have a code when I take height (Hs) and period (Tm) by direction with the index above. Now, I want to save in a table the height and period of the same direction but when I try to do a table I obtain this error.
North_sec = table(Hs_N,Tm_N)
Variable index exceeds table dimensions.
I'm attacching the code below:
fileName = 'D:\Valerio\data\test.mat';
%fileName = 'D:\Valerio\data\IPCC_data_models\ACCESS1_0.mat';
loadfile = load(fileName);
table = loadfile.table_def;
%time_table = table2timetable(loadfile.table_def);
date_array = table.YYMMDD;
hour_array = table.HH;
Hs = table.Hs_tot;
Tm = table.Tm_tot;
Dm = table.Dm_tot;
date_num = datenum(date_array);
North = find((Dm >= 337.5 & Dm <= 360.0) | (Dm >= 0.0 & Dm <= 22.5));
North_East = find(Dm >=22.5 & Dm <= 67.5);
East = find(Dm >=67.5 & Dm <= 112.5);
South_East = find(Dm >=112.5 & Dm <= 157.5);
South = find(Dm >=157.5 & Dm <= 202.5);
South_West = find(Dm >=202.5 & Dm <= 247.5);
West = find(Dm >=247.5 & Dm <= 292.5);
North_West = find(Dm >=292.5 & Dm <= 337.5);
Hs_N = Hs(North);
Hs_NE = Hs(North_East);
Hs_E = Hs(East);
Hs_SE = Hs(South_East);
Hs_S = Hs(South);
Hs_SW = Hs(South_West);
Hs_W = Hs(West);
Hs_NW = Hs(North_West);
Tm_N = Tm(North);
Tm_NE = Tm(North_East);
Tm_E = Tm(East);
Tm_SE = Tm(South_East);
Tm_S = Tm(South);
Tm_SW = Tm(South_West);
Tm_W = Tm(West);
Tm_NW = Tm(North_West);
North_sec = table(Hs_N,Tm_N);
North_East = table(Hs_NE,Tm_NE);
East = table(Hs_E,Tm_E);
South_East = table(Hs_SE,Tm_SE);
South = table(Hs_S,Tm_S);
South_West = table(Hs_SW,Tm_SW);
West = table(Hs_W,Tm_W);
North_West = table(Hs_NW,Tm_NW);
  댓글 수: 1
Rik
Rik 2020년 3월 4일
(removed from spam quarantine)

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

답변 (1개)

Steven Lord
Steven Lord 2020년 3월 4일
table = loadfile.table_def;
While a variable named table exists you cannot call the table function. I recommend clearing the variable and modifying your code to avoid creating a variable with that name.

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by