Skip to content
Snippets Groups Projects
Commit 854864db authored by William Lövfors's avatar William Lövfors
Browse files

Added ConvertData

parent 81402d58
No related branches found
No related tags found
No related merge requests found
function[convertedData]=ConvertData(orgData, varNames, rowNames)
%function[convertedData]=ConvertData(orgData, varNames, rowNames)
% if varnames is not supplied, uses the first column of the table as varNames, and then deletes the column.
% if rowNames is not supplied, the variable names of the input table is used.
% Note that all names are converted to valid variable/row names. In order
% to transpose, the table is converted to a cell array and back. This might
% introduce error, so make sure that the results are as expected!
if nargin<2
varNames=orgData{:,1};
orgData(:,1)=[];
end
if nargin<3
rowNames=orgData.Properties.VariableNames;
end
varNames=matlab.lang.makeValidName(varNames);
rowNames=matlab.lang.makeValidName(rowNames);
t=table2cell(orgData);
convertedData=cell2table(t');
convertedData.Properties.VariableNames=varNames;
convertedData.Properties.RowNames=matlab.lang.makeValidName(rowNames);
end
\ No newline at end of file
function [dupes, ind] = nonunique(A)
[~, i, ~] = unique(A,'first');
dupes = A(not(ismember(1:numel(A),i)));
dupes = unique(A(not(ismember(1:numel(A),i))));
ind=ismember(A,dupes);
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment