Matlab program that runs fine in Windows gives multiple errors in Linux.
1 次查看(过去 30 天)
显示 更早的评论
Both versions are 2012b. The program is:
clear all
matlabpool;
for testSet = 8 %:18
if testSet < 10
load(['MIdata0' int2str(testSet)]);
else
load(['MIdata' int2str(testSet)]);
end
fs = 160;
numberElectrodes = 11;
numberTrialsL = length(squeeze(thinkLeft(1, :, 1)));
numberTrialsR = length(squeeze(thinkRight(1, :, 1)));
% imf(30:end-29)
Left1 = zeros(numberTrialsL, 15, 1312);
Left2 = zeros(numberTrialsL, 15, 1312);
Left3 = zeros(numberTrialsL, 15, 1312);
Left4 = zeros(numberTrialsL, 15, 1312);
Left5 = zeros(numberTrialsL, 15, 1312);
Left6 = zeros(numberTrialsL, 15, 1312);
Left7 = zeros(numberTrialsL, 15, 1312);
Left8 = zeros(numberTrialsL, 15, 1312);
Left9 = zeros(numberTrialsL, 15, 1312);
Left10 = zeros(numberTrialsL, 15, 1312);
Left11 = zeros(numberTrialsL, 15, 1312);
Right1 = zeros(numberTrialsR, 15, 1312);
Right2 = zeros(numberTrialsR, 15, 1312);
Right3 = zeros(numberTrialsR, 15, 1312);
Right4 = zeros(numberTrialsR, 15, 1312);
Right5 = zeros(numberTrialsR, 15, 1312);
Right6 = zeros(numberTrialsR, 15, 1312);
Right7 = zeros(numberTrialsR, 15, 1312);
Right8 = zeros(numberTrialsR, 15, 1312);
Right9 = zeros(numberTrialsR, 15, 1312);
Right10 = zeros(numberTrialsR, 15, 1312);
Right11 = zeros(numberTrialsR, 15, 1312);
midpointL = zeros(numberTrialsL, 1);
midpointR = zeros(numberTrialsR, 1);
parfor currentTrial = 1:12
currentTrial
chanNum = 0;
signalL=[];
signalTotal=[];
matrixDim = 30;
for currentElectrode = [2 6 8 9 11 13 14 16 20 41 42]
chanNum = chanNum + 1;
signalL(chanNum, :) = squeeze(thinkLeft(currentElectrode, currentTrial, :));
signalL3 = [];
% tauStart = find((xcorr(signalL(chanNum, :))==max(xcorr(signalL(chanNum, :)))));
% tauEnd = find((xcorr(signalL(chanNum, :))==min(xcorr(signalL(chanNum, :)))));
% tau = abs(tauEnd-tauStart);
tau=1;
for window = 1:length(signalL(chanNum, :))-matrixDim+1
signalL3(window, :) = signalL(chanNum, window:window+matrixDim-1);
end
signalTotal = [signalTotal; signalL3'];
end
%x = memd(signalTotal, length(signalTotal(:, 1)) * 2);
x = ones(length(signalTotal(:, 1)), 13, length(signalTotal(1, :)));
for currentElectrode = 1:11
xxl = zeros(length(squeeze(x(1, :, 1))), length(signalL(1, :)));
for imfNo = 1:length(squeeze(x(1, :, 1)))
currentSignal = squeeze(x(:, imfNo, :));
for zzz = 1:length(signalL(currentElectrode, :))-matrixDim+1
xxl(imfNo, zzz:zzz+matrixDim-1) = xxl(imfNo, zzz:zzz+matrixDim-1) + (x((currentElectrode-1)*30+1:currentElectrode*30, imfNo, zzz))';
end
xxl(imfNo, :) = xxl(imfNo, :)/matrixDim;
end
****midpointL(currentTrial, :) = length(xxl(:, 1));****
for yyy = 1:15-length(xxl(:, 1))
xxl = [xxl; zeros(1, length(xxl(1, :)))];
end
if currentElectrode == 1
Left1(currentTrial, :, :) = xxl;
elseif currentElectrode == 2
Left2(currentTrial, :, :) = xxl;
****elseif currentElectrode == 3
Left3(currentTrial, :, :) = xxl;
elseif currentElectrode == 4
Left4(currentTrial, :, :) = xxl;
elseif currentElectrode == 5
Left5(currentTrial, :, :) = xxl;
elseif currentElectrode == 6
Left6(currentTrial, :, :) = xxl;
elseif currentElectrode == 7
Left7(currentTrial, :, :) = xxl;
elseif currentElectrode == 8
Left8(currentTrial, :, :) = xxl;
elseif currentElectrode == 9
Left9(currentTrial, :, :) = xxl;
elseif currentElectrode == 10
Left10(currentTrial, :, :) = xxl;
elseif currentElectrode == 11
Left11(currentTrial, :, :) = xxl;****
end
end
end
parfor currentTrial = 1:12
currentTrial
chanNum = 0;
signalL=[];
signalTotal=[];
matrixDim = 30;
for currentElectrode = [2 6 8 9 11 13 14 16 20 41 42]
chanNum = chanNum + 1;
signalL(chanNum, :) = squeeze(thinkRight(currentElectrode, currentTrial, :));
signalL3 = [];
% tauStart = find((xcorr(signalL(chanNum, :))==max(xcorr(signalL(chanNum, :)))));
% tauEnd = find((xcorr(signalL(chanNum, :))==min(xcorr(signalL(chanNum, :)))));
% tau = abs(tauEnd-tauStart);
tau=1;
for window = 1:length(signalL(chanNum, :))-matrixDim+1
signalL3(window, :) = signalL(chanNum, window:window+matrixDim-1);
end
signalTotal = [signalTotal; signalL3'];
end
% x = memd(signalTotal, length(signalTotal(:, 1)) * 2);
x = ones(length(signalTotal(:, 1)), 15, length(signalTotal(1, :)));
for currentElectrode = 1:11
xxl = zeros(length(squeeze(x(1, :, 1))), length(signalL(1, :)));
for imfNo = 1:length(squeeze(x(1, :, 1)))
currentSignal = squeeze(x(:, imfNo, :));
for zzz = 1:length(signalL(currentElectrode, :))-matrixDim+1
xxl(imfNo, zzz:zzz+matrixDim-1) = xxl(imfNo, zzz:zzz+matrixDim-1) + (x((currentElectrode-1)*30+1:currentElectrode*30, imfNo, zzz))';
end
xxl(imfNo, :) = xxl(imfNo, :)/matrixDim;
end
****midpointR(currentTrial, :) = length(xxl(:, 1));****
for yyy = 1:15-length(xxl(:, 1))
xxl = [xxl; zeros(1, length(xxl(1, :)))];
end
if currentElectrode == 1
Right1(currentTrial, :, :) = xxl;
elseif currentElectrode == 2
Right2(currentTrial, :, :) = xxl;
****elseif currentElectrode == 3
Right3(currentTrial, :, :) = xxl;
elseif currentElectrode == 4
Right4(currentTrial, :, :) = xxl;
elseif currentElectrode == 5
Right5(currentTrial, :, :) = xxl;
elseif currentElectrode == 6
Right6(currentTrial, :, :) = xxl;
elseif currentElectrode == 7
Right7(currentTrial, :, :) = xxl;
elseif currentElectrode == 8
Right8(currentTrial, :, :) = xxl;
elseif currentElectrode == 9
Right9(currentTrial, :, :) = xxl;
elseif currentElectrode == 10
Right10(currentTrial, :, :) = xxl;
elseif currentElectrode == 11
Right11(currentTrial, :, :) = xxl;****
end
end
end
****if testSet < 10
save(['STMEMDdata0' int2str(testSet) '.mat'], 'Left1', 'Left2', 'Left3', 'Left4', 'Left5', 'Left6', 'Left7', 'Left8', 'Left9', 'Left10', 'Left11',...
'midpointL', 'Right1', 'Right2', 'Right3', 'Right4', 'Right5', 'Right6', 'Right7', 'Right8', 'Right9', 'Right10', 'Right11', 'midpointR');
else
save(['STMEMDdata' int2str(testSet) '.mat'], 'Left1', 'Left2', 'Left3', 'Left4', 'Left5', 'Left6', 'Left7', 'Left8', 'Left9', 'Left10', 'Left11',...
'midpointL', 'Right1', 'Right2', 'Right3', 'Right4', 'Right5', 'Right6', 'Right7', 'Right8', 'Right9', 'Right10', 'Right11', 'midpointR');
end****
end
matlabpool close;
The lines highlighted with asterisks are the ones that cause it to freak out on Linux.
midpointL(currentTrial, :) = length(xxl(:, 1));
The above causes a fatal Segmentation Violation that forces Matlab to close. The same happens with the code that saves the data as STMEMD.mat
elseif currentElectrode == 3.....
The above code gives an error saying there's a subscripted dimension mismatch in the "parallel" function itself when called by "parfor currentTrial = 1:12". What's weird is that it works fine with the first two if statements preceeding it. There is literally no difference between the results of "currentElectrode == 3" and "currentElectrode == 2". Matrix dimensions are identical. In fact the error doesn't display until the program tries to exit the parfor loop.
Occasionally get inconsistent Segmentation Violation crashes on other lines but it's intermittent.
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!