Performance Issue detected in Table vs Struct Data

5 ビュー (過去 30 日間)
Tobias Poniatowski
Tobias Poniatowski 2019 年 2 月 28 日
コメント済み: Peter Perkins 2019 年 3 月 11 日
% Hello Mathworks Team,
% our development Team found an issue when writing data into specific positions of a data column of a table.
% Comparing the performance with writing into an array of a struct we was wondering if this is intended or if it could be an issue in the software?
% Could you give us an answer if we should address the data of a table differently?
% Thanks in advance and best Regards.
% Tobias Poniatowski
testData = zeros(100000,1);
testValueToWrite = 4711;
testStruct.data = testData;
testTable = table(testData, 'VariableNames', {'data'});
ticStruct = tic;
for i=1:size(testStruct.data,1)
testStruct.data(i) = testValueToWrite;
end
toc(ticStruct)
ticTable = tic;
for i=1:size(testTable.data,1)
testTable.data(i) = testValueToWrite;
end
toc(ticTable)
% result:
% Elapsed time is 0.025719 seconds.
% Elapsed time is 13.884480 seconds.
  1 件のコメント
Peter Perkins
Peter Perkins 2019 年 3 月 11 日
Tobias, as comments in the links that Harshita cites suggest, using vectorized operations is a better strategy. Your code example is so stripped down that it's impossible to give you any real advice, but I imagine that you could contact MathWorks support for help.

サインインしてコメントする。

採用された回答

Harshita Gupta
Harshita Gupta 2019 年 3 月 4 日

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by