help me debug this script!
1 次查看(过去 30 天)
显示 更早的评论
Hi I have this script:
%%this script produces the anova1 values for n1-35 in session 1
n = 1:35
dataset_pfc_tar_57_n = dataset_pfc_tar_57(n,:)
%%toreplicate into 8 rows
testdata_n = repmat(dataset_pfc_tar_57_n, 8,1)
pfc_n = testdata_n.*ixCopy
%%to Nan only those in ixCopy, not actual 0 values in dataset
pfc_n (ixCopy ==0) = NaN
%%transpose pfc_n for anova to work
p = anova1(pfc_n')
With this, I am returned with the prompt: Matrix dimensions must agree. However, I am unable to find out where they do not agree.
testdata_n = 8 x 621 double
ixCopy = 8 x 621 logical
The goal is to have the script produce 35 pvalues. Let me know the improvements I should make to my script. Thank you, any help is much appreciated!
0 个评论
采纳的回答
Walter Roberson
2019-9-17
n = 1:35
dataset_pfc_tar_57_n = dataset_pfc_tar_57(n,:)
With n being a vector of length 35, dataset_pfc_tar_57_n is going to have 35 rows and some number of columns that I will call COL
testdata_n = repmat(dataset_pfc_tar_57_n, 8,1)
Those rows are going to be replicated 8 times, giving you 280 rows and COL columns.
pfc_n = testdata_n.*ixCopy
You are multiplying a 280 x COL matrix element-wise by something you have said is 8 x 621. We could hypothesize that COL is 621, so the widths might be equal, but you cannot use .* between a 280 x 621 and an 8 x 621.
Now, if n were a scalar instead of a vector then everything would work out.
3 个评论
Walter Roberson
2019-9-17
%%this script produces the anova1 values for n1-35 in session 1
p = zeros(1,35);
for n = 1:35
dataset_pfc_tar_57_n = dataset_pfc_tar_57(n,:)
%%toreplicate into 8 rows
testdata_n = repmat(dataset_pfc_tar_57_n, 8,1)
pfc_n = testdata_n.*ixCopy
%%to Nan only those in ixCopy, not actual 0 values in dataset
pfc_n (ixCopy ==0) = NaN
%%transpose pfc_n for anova to work
p(n) = anova1(pfc_n');
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Analysis of Variance and Covariance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!