English 中文(简体)
为什么在牢房中储存的数据比在矩阵中少?
原标题:why are access times to data stored in cells shorter than in matrices?

I m处理材料中的非常大的数据,用于在矩阵中储存这些数据。 我用的是逐行储存我的数据,但由于马特拉布特储存数据一栏,我的理解是,按一栏重新调整我的矩阵,使处理速度更快。 我指的是:


<>一般参数>

nbr_channels = 20;
nbr_samples_per_channel = 3200000;
fake_data = randn(1, nbr_samples_per_channel);
ROI = 1200000 : 2800000;

<>/>传输数据

data = nan(nbr_channels, nbr_samples_per_channel);
tic; 
for j = 1 : nbr_channels
    data(j, 1:nbr_samples_per_channel) = fake_data; 
end; 
toc;

% Elapsed time is 1.476525 seconds.

return data fromrowmap

tic; 
for j = 1 : nbr_channels
    bla = data(j, ROI); 
end; 
toc;

% Elapsed time is 0.572162 seconds.

http://www.ohchr.org。

tic; 
for j = 1 : nbr_channels
    bla = data(j, :); 
end; 
toc;

% Elapsed time is 0.589489 seconds.

<>0>按栏目分列的数据

data = nan(nbr_samples_per_channel, nbr_channels);
tic; 
for j = 1 : nbr_channels
    data(1:nbr_samples_per_channel, j) = fake_data; 
end; 
toc;

% Elapsed time is 0.299682 seconds.

<>中程>数据

tic; 
for j = 1 : nbr_channels
    bla = data(ROI, j); 
end; 
toc;

% Elapsed time is 0.260824 seconds.

<>恢复矩阵表所有数据>

tic; 
f    or j = 1 : nbr_channels
    bla = data(:, j); 
end; 
toc;

% Elapsed time is 0.092983 seconds.

www.un.org/Depts/DGACM/index_spanish.htm 概述1:

我们能够看到,通过一栏获取数据至少可减少处理时间两倍!

但我不理解为什么囚室效率更高! 举一个例子:

<ssign data by cell

data = cell(1, nbr_samples_per_channel);
tic; 
for j = 1 : nbr_channels
    data{j} = fake_data; 
end; 
toc;

% Elapsed time is 0.000013 seconds.

return data from cell range

tic; 
for j = 1 : nbr_channels
    bla = data{j}(ROI); 
end; 
toc;

% Elapsed time is 0.260294 seconds.

<>恢复从电池阵列获得的所有数据>

tic; 
for j = 1 : nbr_channels
    bla = data{j}; 
end; 
toc;

% Elapsed time is 0.000022 seconds.

%%

www.un.org/Depts/DGACM/index_spanish.htm 摘要2:

这是比我在第1部分所显示的更快程度的指令。

<><><><><><>><>>><>>>>>>

为什么在牢房中储存的数据比在矩阵中少?

Question 2

与矩阵相关的工作一般比与电池更容易,因为可以通过矩阵进行。

my_matrix(100:20000,1:3>

but with cells I can t do this (as far as I know). Any alternatives on how to return specific elements from multiple cells at the same time?

最佳回答

你看到不同的时代,因为你没有做同样的事。 比较你的两个案件:

assign data by cell

  • 你们正在制造一个细胞阵容病媒,在每间囚室的双向下戴上双双双双双双管束。

  • 每一环形扰动导致1个病媒被分配到一个细胞阵列的单一位置。

  • There are nbr_samples_per_channel number of assignments being done.

<>0>按栏目分列的数据

  • 页: 1

  • 不管短处殖民地如何,每一次游乐团都决心完成许多任务。 数据(1:nbr_samples_per_channel, j)是指Nbr_samples_per_channelsign PERERation。

  • overall, you are doing nbr_samples_per_channel * nbr_channels total assignments.

To make my point, just re-write the loop without the colon operator to visualize all the assignments.

for j = 1 : nbr_channels    

    n = length(fake_data)

    data(1,     j) = fake_data(1); 
    data(2,     j) = fake_data(1); 

    ... etc ...

    data(n - 1, j) = fake_data(n-1); 
    data(n,     j) = fake_data(n); 

end

So, to conclude, you are comparing two different things, so you can t say one is really faster than the other, because they are not equivalent.

如果你只停留在两阵列和囚室,并经常执行任务。

%% Setup samples and pre-allocate
numberOfSamples = 100000;

doubleData = nan(numberOfSamples, 1);
cellData = cell(numberOfSamples, 1);

randomValues = rand(numberOfSamples, 1);

%% Assign N number of values to a double array
tic; 
for idx = 1 : numberOfSamples
    data(numberOfSamples) = randomValues(idx);
end
doubleTime = toc;

%% Assign N number of values to a cell array
tic; 
for idx = 1 : numberOfSamples
    cellData{numberOfSamples} = randomValues(idx);
end
cellTime = toc;

disp(sprintf( Double Array: %f seconds , doubleTime));
disp(sprintf( Cell   Array: %f seconds , cellTime));

最后,请:

Double Array: 0.006073 seconds
Cell   Array: 0.032966 seconds

您的第二个问题是,你试图做些什么?

>> bigCell = {1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16}

bigCell = 

    [ 1]    [ 2]    [ 3]    [ 4]
    [ 5]    [ 6]    [ 7]    [ 8]
    [ 9]    [10]    [11]    [12]
    [13]    [14]    [15]    [16]

>> subCell = bigCell(1:2, 3:4)

subCell = 

    [3]    [4]
    [7]    [8]

关于子细胞的通知。 通过使用(......) s而不是{}进入囚室,你将其保留为囚室。

问题回答

暂无回答




相关问题
What to look for in performance analyzer in VS 2008

What to look for in performance analyzer in VS 2008 I am using VS Team system and got the performance wizard and reports going. What benchmarks/process do I use? There is a lot of stuff in the ...

SQL Table Size And Query Performance

We have a number of items coming in from a web service; each item containing an unknown number of properties. We are storing them in a database with the following Schema. Items - ItemID - ...

How to speed up Visual Studio 2008? Add more resources?

I m using Visual Studio 2008 (with the latest service pack) I also have ReSharper 4.5 installed. ReSharper Code analysis/ scan is turned off. OS: Windows 7 Enterprise Edition It takes me a long time ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

热门标签