Dot indexing not supportedd

10 ビュー (過去 30 日間)
Farrah Vogel-Javeri
Farrah Vogel-Javeri 2020 年 12 月 10 日
編集済み: Jon 2020 年 12 月 10 日
I am trying to write a function which converts all answers to a Likart survey to 1 and 0. The code itself works, but when I trz to run the function itself i get an error stating "Dot indexing is not supported for variables of this type.
Error in funclikart2 (line 5)
header = T.Properties.VariableNames; % keep table variable names"
This is my code:
function T = funclikart2(tabName, sheetnumber)
% check input data type if necessary
T = xlsread(tabName, sheetnumber);
header = T.Properties.VariableNames; % keep table variable names
yesIdx = ismember(lower(T), {'agree', 'strongly agree'}); % index of YES answers
T(yesIdx) = 1; T(~yesIdx) = 0; % assign 1/0 values
T = array2table(T, 'VariableNames', header); % convert back to table
end % END
Can anyone help me out?

回答 (1 件)

Jon
Jon 2020 年 12 月 10 日
編集済み: Jon 2020 年 12 月 10 日
T = xlsread( ) returns an array of double values, not a table so T.xxx is not meaningful
I suggest using readtable instead.

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by