Numeric data becomes zero after conversion from Table

I am trying to extract data collected via IMU using the readtable function like this:
%Extracting data from the LGW folder
[filename, pathname] = uigetfile('*.dat');
T1 = readtable(strcat(pathname,filename),"ReadVariableNames",true);
T1 = T1(:,1:end-2);
[filename, pathname] = uigetfile('*.dat');
T2 = readtable(strcat(pathname,filename));
T2 = T2(:,1:end-2);
[filename, pathname] = uigetfile('*.dat');
T3 = readtable(strcat(pathname,filename));
T3 = T3(:,1:end-2);
[filename, pathname] = uigetfile('*.dat');
T4 = readtable(strcat(pathname,filename));
T4 = T4(:,1:end-2);
T4(:,[51 52]) = [];
[filename, pathname] = uigetfile('*.dat');
T5 = readtable(strcat(pathname,filename));
T5 = T5(:,1:end-2);
T5(:,[51 52]) = [];
[filename, pathname] = uigetfile('*.dat');
T6 = readtable(strcat(pathname,filename));
T6 = T6(:,1:end-2);
T6(:,[51 52]) = []
However, when converting it to numeric data like this:
nums = [LGW_Pelvis{2,:}]
The data becomes zero except for the all the row under the first column.
I have tried changing the format into cell and timetable but when getting the numeric data format from these data types: they becomes zero.

8 个评论

please show us
unique(varfun(@class, LGW_Pelvis, 'OuputFormat', 'cell'))
It is displaying
Incorrect number or types of inputs or outputs for function 'varfun'.
unique(varfun(@class, LGW_Pelvis, 'OutputFormat', 'cell'))
% ^ fix spelling mistake
It is still displaying the same error as I mentioned earlier.
You show us code for constructing several table objects, and then you show us a variable name that does not match any of the table objects without showing us how you constructed the variable.
%Clustering the data as one stack for LGW
data_LGW = [T1;T2;T3;T4;T5;T6;T7;T8;T9;T10;T11;T12];
%Extract Pelvis data from the respective mode of activity
LGW_Pelvis = table2cell(data_LGW(1:19187,61:70))
Okay, please show us
unique(varfun(@class, data_LGW(1,61:70), 'OutputFormat', 'cell'))
ans = 1×1 cell array
{'double'}
This is the given output.

请先登录,再进行评论。

 采纳的回答

I predict that you have
format short
in effect, and that what is being displayed is not really 0 but is instead something of the form
x = [0,10.^(-5:5)]
x = 1×12
1.0e+05 * 0 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0010 0.0100 0.1000 1.0000
Notice the initial "1.0e+5 *" before the line, and notice the "0.0000" entries. The "1.0e+5 *" indicates that you need to mentally multiply all of the displayed outputs by 1.0e+5. The 0.0000 entries indicate something that is not exactly zero, but instead is smaller than 0.0001 times the value shown in the first line. Notice the exact 0 at the begining is shown without the ".0000" .
I predict that if you were to
format long g
x
x = 1×12
1.0e+00 * 0 1e-05 0.0001 0.001 0.01 0.1 1 10 100 1000 10000 100000
then you would see the actual values.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Tables 的更多信息

产品

版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by