필터 지우기
필터 지우기

help me debug this script!

조회 수: 3 (최근 30일)
Cside
Cside 2019년 9월 17일
댓글: Cside 2019년 9월 17일
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!

채택된 답변

Walter Roberson
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
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
Cside
Cside 2019년 9월 17일
thank you Walter, really appreciate it :) have a good day!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile 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!

Translated by