writing code so that for loop does not overwrite
1 次查看(过去 30 天)
显示 更早的评论
Hi, I currently have this code and would like to NOT have the for loop overwrite with every t so that there will be 11 selectiven. How can i rewrite the problem line to make sure the for loop does not overwrite and produce 11 selectiven matrices? Thank you! :)
for t = 43:53
C= A(:,:,t);
for i = 1:8
D = find(sessions_pfc==i);
trialsize = size(trials(i).val);
B = ix_all(i);
B2 = cell2mat(B);
[locations,~] = find(B2);
anss = 0;
for n = D(1,:):D(end)
p= anova1(C(n,1:trialsize(:,2)), locations', 'off');
anss=anss+(p<0.05);
selectiven (n,:) = p<0.05
end
end
neuronno(t) = find (selectiven); %%problem line
end
0 个评论
回答(1 个)
KALYAN ACHARJYA
2019-12-1
编辑:KALYAN ACHARJYA
2019-12-1
#Edited
neuronno(t) = find (selectiven);
As the t indices starts from 43 till 53. Here what about the previous indexing? Better to choose other variable name to avoid zeros or [ ] at initials-
%Drfine k=1 before first for loop
neuronno(k) = find (selectiven);
k=k+1;
Still problem, let me kow?
5 个评论
KALYAN ACHARJYA
2019-12-1
编辑:KALYAN ACHARJYA
2019-12-1
OK, May be in each iteration the following statement gives the same results
>> find(selectiven)
ans =
1
Right? Is this statement complete? Based on my basic undestanding you may get the following results for neuronno
neuronno=[0 0 0 0 0.....................till 42 index then 1 1 1 1 1 1 1 1 1 1]
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!