如何在Matlab中使用for循环在结构中赋值?

时间:2015-10-22 06:30:42

标签: matlab

function [den, p] = findUpperBound(data)
newData = data;
ranData = data;
pValue = Inf;
density = 0.99;
decr = 0.01;
x = [];
y = [];
while(pValue>0.05)
   for i=1:numel(data)
       newData(i).matrix = findNetworkAtDensity(density, 0.01, data(i).matrix);
       newData(i).smallWorldness = (sum(clustering_coef_wu(newData(i).matrix))/90)/avgPathLen(newData(i).matrix);
       x(i,1) = newData(i).matrix; 
       ranData(i).matrix = randmio_und_connected(newData(i).matrix, 5);
       ranData(i).smallWorldness = (sum(clustering_coef_wu(ranData(i).matrix))/90)/avgPathLen(ranData(i).matrix);
       y(i,1) = ranData(i).matrix;
   end
   [h, pValue] = ttest2(x,y);
   density = density - decr;
end
den = density;
p = pValue;

我需要为newData和ranData分配一些值,并且出现错误:

"Improper index matrix reference. Error in findUpperBound (line 11)newData(i).matrix = findNetworkAtDensity(density, 0.01, data(i).matrix);"

奇怪的是,如果我使用命令窗口执行此操作,则不会出现错误:

>> a = data;
>> a(1).matrix = data(1).matrix;
>> 

我已经在Matlab网站上搜索了这个,但仍然无法找到答案。 谁能告诉我如何解决这个问题?非常感谢!

0 个答案:

没有答案