Is there a way to access the column data without having to type table_name.VariableName (:,:)
? I need to find the delta time from the time stamp of the data. This is what I have done so far:
[u,v]=size(a);
b=cell2table(cell(u,1));
for i=1:u
if i==1
b(i,1)={'0'};
else
b(i,1)=(datenum(a.PCTimestamp_None_(i,1)) ...
-datenum(a.PCTimestamp_None_(i-1,1)))+str2double(b{i-1,1});
end
end
The problem, I am having is, the time stamp is always in column 1. So I am looking for a way to access data just by mentioning first column instead of variable name.
Any help would be appreciated.
答案 0 :(得分:0)
您可以使用花括号来索引表,而无需指定与目标列关联的变量名。卷曲括号也可用于更直接地分配/检索内部单元格值。
[u,v] = size(a);
b = cell(u,1);
b{1} = 0;
for i = 2:u
b{i} = (datenum(a{i,1}) - datenum(a{i-1,1})) + b{i-1};
end
b = cell2table(b);
答案 1 :(得分:0)
表变量可以通过索引t.(1)
以及名称
t = table(ones(3, 1), rand(3, 1), 'VariableNames', {'foo', 'bar'});
assert(isequal(t.bar, t.(2)));