Clear Filters
Clear Filters

How to do a ttest2 between two 4D matrices?

1 view (last 30 days)
HA
HA on 20 Apr 2018
Edited: Matt J on 20 Apr 2018
I have two 4D matrices that I would like to do a ttest2 between to determine their relation at each point. The problem is that ttest2 only does the first element of the matrices, so I end up with a new matrix of dimension 1x128x17x12 from 64x128x17x12.
I have tried doing a for loop through:
for q=1:64
A(q,:,:,:)=ttest2(B,C);
end
However this just repeats the ttest for (1,:,:,:) for all 64 loops. I have tried putting the loop in each of B and C and even tried a nested loop but I end up getting the same problems.
Is there anyway I can get the full 4D matrix for each point from ttest2?

Accepted Answer

Matt J
Matt J on 20 Apr 2018
Edited: Matt J on 20 Apr 2018

I have tried doing a for loop through... for q=1:64

Meaning you want 64 t-test results? If so, then you could do as follows

A = ttest2(B(:,:).', C(:,:).')
  2 Comments
HA
HA on 20 Apr 2018
not quite, I would like a final matrix output of 64x128x17x12, that way I can tell which parts of the two are similar, and therefore plot only the significant results? Is there anyway to do this with ttest2?
Thank you for your reply, it may well be that I am using the wrong statistical test for what I want to do perhaps?
Matt J
Matt J on 20 Apr 2018
Edited: Matt J on 20 Apr 2018
But what are the dimensions of B and C? Which dimension corresponds to the different samples/observations on which each individual test result will be based?

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!