I changed matrix dimension by this>>

VC_1_new=permute(VC_1,[2 3 1]);

but I get the wrong answer again

load VC_1.mat;

VC_1_new=permute(VC_1,[2 3 1]);

chan2use=17;% 17= Cz

pnts=size(VC_1_new,2);

trials=size(VC_1_new,3);

data = squeeze(VC_1_new( chan2use, :,:));

EEG_times=[1:307]/256-0.2;

% frequency parameters

min_freq = 2;

max_freq = 30;

num_frex = 40;

frex = linspace(min_freq,max_freq,num_frex);

% other wavelet parameters

range_cycles = [ 4 10 ];

srate=256;

s = logspace(log10(range_cycles(1)),log10(range_cycles(end)),num_frex) ./ (2*pi*frex);

wavtime = -2:1/srate:2;

half_wave = (length(wavtime)-1)/2;

tic; % start matlab timer

% FFT parameters

nWave = length(wavtime);

nData = pnts;

nConv = nWave + nData - 1;

% initialize output time-frequency data

tf = zeros(length(frex),pnts,trials);

% loop over frequencies

for fi=1:length(frex)

```
% create wavelet and get its FFT
% the wavelet doesn't change on each trial...
wavelet = exp(2*1i*pi*frex(fi).*wavtime) .* exp(-wavtime.^2./(2*s(fi)^2));
waveletX = fft(wavelet,nConv);
waveletX = waveletX ./ max(waveletX);
% now loop over trials...
for triali=1:trials
dataX=fft(squeeze(VC_1_new(chan2use,:,triali)),nConv);
```

% dataX = fft(squeeze(EEG.data(strcmpi(channel2use,{EEG.chanlocs.labels}),:,triali)), nConv);

```
% run convolution
as = ifft(waveletX .* dataX);
as = as(half_wave+1:end-half_wave);
% put power data into big matrix
tf(fi,:,triali) = abs(as).^2;
end
```

end

tfTrialAve = mean(tf,3);

computationTime = toc; % end matlab timer for this cell

% plot results

figure(1), clf

contourf(EEG_times,frex,tfTrialAve,40,‘linecolor’,‘none’)

set(gca,‘clim’,[0 5],‘ydir’,‘normal’,‘xlim’,[-300 1000])