diff --git a/API/parseClassToStructs.m b/API/parseClassToStructs.m index 4d8386272..faeb5b766 100644 --- a/API/parseClassToStructs.m +++ b/API/parseClassToStructs.m @@ -90,34 +90,16 @@ % Each cell is {1 x Inf char} -% First parse the class to a structure variable. +%% First parse the class to a structure variable. inputStruct = project.toStruct(); -%% Start by removing the cell arrays -contrastLayers = inputStruct.contrastLayers; -layerDetails = inputStruct.layerDetails; - -% If any of the contrastLayers are empty, replace the empty cells by zero -% thickness layers -for i = 1:length(contrastLayers) - thisLayer = contrastLayers{i}; - if isempty(thisLayer) - contrastLayers{i} = 0; - end -end - -% Do the same for layerDetails -if isempty(layerDetails) - layerDetails = {0}; -end - -% Pull out all the cell arrays (except priors) into one array +%% Pull out all the cell arrays (except priors) into one array problemCells{1} = inputStruct.contrastRepeatSLDs; problemCells{2} = inputStruct.data; problemCells{3} = inputStruct.dataLimits; problemCells{4} = inputStruct.simLimits; -problemCells{5} = contrastLayers; -problemCells{6} = layerDetails; +problemCells{5} = inputStruct.contrastLayers; +problemCells{6} = inputStruct.layerDetails; problemCells{7} = inputStruct.paramNames; problemCells{8} = inputStruct.backgroundParamNames; problemCells{9} = inputStruct.scalefactorNames; @@ -137,39 +119,15 @@ % Now deal with domains cell arrays if isa(project, 'domainsClass') && isa(project.domainContrasts, 'domainContrastsClass') - - domainContrastLayers = inputStruct.domainContrastLayers; - - % If any of the domainContrastLayers are empty, replace the empty - % cells by zero thickness layers - for i = 1:length(domainContrastLayers) - thisLayer = domainContrastLayers{i}; - if isempty(thisLayer) - domainContrastLayers{i} = 0; - end - end problemCells{18} = inputStruct.domainContrastRepeatSLDs; - problemCells{19} = domainContrastLayers; + problemCells{19} = inputStruct.domainContrastLayers; end if isa(project, 'domainsClass') problemCells{20} = inputStruct.domainRatioNames; end -% Fix for cell array bug with custom layers - is this needed still?? -if strcmpi(inputStruct.modelType,'custom layers') || strcmpi(inputStruct.modelType,'custom xy') - for i = 1:length(problemCells{5}) - problemCells{5}{i} = 0; - end - for i = 1:length(problemCells{19}) - problemCells{19}{i} = 0; - end - - problemCells{6} = {0}; - -end - % Also the custom files array.. if isempty(problemCells{14}) problemCells{14} = {''}; diff --git a/API/projectClass/contrastsClass.m b/API/projectClass/contrastsClass.m index 844977092..f47a4dd59 100644 --- a/API/projectClass/contrastsClass.m +++ b/API/projectClass/contrastsClass.m @@ -108,7 +108,7 @@ contrastLayers{i} = thisArray; contrastCustomFile(i) = NaN; otherwise - contrastLayers{i} = {}; + contrastLayers{i} = []; whichFile = thisContrast.model; thisContrastFileNum = find(strcmpi(whichFile, allowedNames.customFileNames)); contrastCustomFile(i) = thisContrastFileNum; diff --git a/targetFunctions/common/groupLayers/allocateLayersForContrast.m b/targetFunctions/common/groupLayers/allocateLayersForContrast.m index a69457f61..7dc15ee7b 100644 --- a/targetFunctions/common/groupLayers/allocateLayersForContrast.m +++ b/targetFunctions/common/groupLayers/allocateLayersForContrast.m @@ -1,4 +1,4 @@ -function thisContrastLayers = allocateLayersForContrast(contrastLayers,outParameterisedLayers,useImaginary) +function thisContrastLayers = allocateLayersForContrast(contrastLayers,outParameterisedLayers,useImaginary) % Decide which layers are needed for a particular contrast. % This function takes the master array of all layers % and extracts which parameters are required for @@ -8,8 +8,6 @@ % outParameterisedLayers - List of all the available layers % thisContrastLayers - Array detailing which layers are required for this contrast -coder.varsize('thisContrastLayers',[1000 6],[1 1]); - if useImaginary thisContrastLayers = zeros(length(contrastLayers),6); else @@ -17,11 +15,7 @@ end for i = 1:length(contrastLayers) - if (contrastLayers(i) ~= 0) - thisContrastLayers(i,:) = outParameterisedLayers{contrastLayers(i)}; - else - thisContrastLayers(i,:) = []; - end + thisContrastLayers(i,:) = outParameterisedLayers{contrastLayers(i)}; end end diff --git a/targetFunctions/common/resampleLayers/SLDFunction.m b/targetFunctions/common/resampleLayers/SLDFunction.m index b52f9065b..3cd5974bb 100644 --- a/targetFunctions/common/resampleLayers/SLDFunction.m +++ b/targetFunctions/common/resampleLayers/SLDFunction.m @@ -26,11 +26,9 @@ if ~isempty(where) sldVal = rho(where); else - belowVals = find(x > z); - aboveVals = find(x < z); - below = belowVals(end); - above = aboveVals(1); - + below = find(x > z, 1, 'last'); + above = find(x < z, 1); + belowY = rho(below); aboveY = rho(above); diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomLayersInputs.mat b/tests/domainsTFReflectivityCalculation/domainsCustomLayersInputs.mat index 237d41d14..7f517b5c7 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomLayersInputs.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomLayersInputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomLayersOutputs.mat b/tests/domainsTFReflectivityCalculation/domainsCustomLayersOutputs.mat index 21bdc36b6..deceee41d 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomLayersOutputs.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomLayersOutputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomLayersTFParams.mat b/tests/domainsTFReflectivityCalculation/domainsCustomLayersTFParams.mat index 995faf462..95bb113a3 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomLayersTFParams.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomLayersTFParams.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat b/tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat index bad160d90..bfba66eb1 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomXYInputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat b/tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat index 499d72383..43f8f70c8 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomXYOutputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsCustomXYTFParams.mat b/tests/domainsTFReflectivityCalculation/domainsCustomXYTFParams.mat index 11983e4c1..112751057 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsCustomXYTFParams.mat and b/tests/domainsTFReflectivityCalculation/domainsCustomXYTFParams.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsStandardLayersInputs.mat b/tests/domainsTFReflectivityCalculation/domainsStandardLayersInputs.mat index de4c117d8..0db76e342 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsStandardLayersInputs.mat and b/tests/domainsTFReflectivityCalculation/domainsStandardLayersInputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsStandardLayersOutputs.mat b/tests/domainsTFReflectivityCalculation/domainsStandardLayersOutputs.mat index 20c9b79ad..850a83985 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsStandardLayersOutputs.mat and b/tests/domainsTFReflectivityCalculation/domainsStandardLayersOutputs.mat differ diff --git a/tests/domainsTFReflectivityCalculation/domainsStandardLayersTFParams.mat b/tests/domainsTFReflectivityCalculation/domainsStandardLayersTFParams.mat index c04167d33..659e366e9 100644 Binary files a/tests/domainsTFReflectivityCalculation/domainsStandardLayersTFParams.mat and b/tests/domainsTFReflectivityCalculation/domainsStandardLayersTFParams.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat b/tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat index 60a1fd61d..4882b624d 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/customLayersInputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customLayersOutputs.mat b/tests/nonPolarisedTFReflectivityCalculation/customLayersOutputs.mat index ce5c0826a..c60a6c8ae 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customLayersOutputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/customLayersOutputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customLayersTFParams.mat b/tests/nonPolarisedTFReflectivityCalculation/customLayersTFParams.mat index 682b6da3e..20b9a3913 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customLayersTFParams.mat and b/tests/nonPolarisedTFReflectivityCalculation/customLayersTFParams.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat b/tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat index 8d17d80c2..d119599fe 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/customXYInputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat b/tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat index ac926f116..1a6c3abc8 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/customXYOutputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat b/tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat index 9f28ce4d7..6f6a3b942 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat and b/tests/nonPolarisedTFReflectivityCalculation/customXYTFParams.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/standardLayersInputs.mat b/tests/nonPolarisedTFReflectivityCalculation/standardLayersInputs.mat index 7ae3f374b..c664a2175 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/standardLayersInputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/standardLayersInputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/standardLayersOutputs.mat b/tests/nonPolarisedTFReflectivityCalculation/standardLayersOutputs.mat index 8b0572b53..e40b4df39 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/standardLayersOutputs.mat and b/tests/nonPolarisedTFReflectivityCalculation/standardLayersOutputs.mat differ diff --git a/tests/nonPolarisedTFReflectivityCalculation/standardLayersTFParams.mat b/tests/nonPolarisedTFReflectivityCalculation/standardLayersTFParams.mat index d8bd5d945..584509d30 100644 Binary files a/tests/nonPolarisedTFReflectivityCalculation/standardLayersTFParams.mat and b/tests/nonPolarisedTFReflectivityCalculation/standardLayersTFParams.mat differ diff --git a/tests/testContrastsClass.m b/tests/testContrastsClass.m index 6a1098e18..3fcb4955b 100644 --- a/tests/testContrastsClass.m +++ b/tests/testContrastsClass.m @@ -499,7 +499,7 @@ function testToStructCustomLayers(testCase) for i=1:testCase.numContrasts testCase.exampleClass.contrasts{i}.model = {'DSPC Model'}; end - testCase.exampleStruct.contrastLayers = {{} {} {}}; + testCase.exampleStruct.contrastLayers = {[] [] []}; testCase.exampleStruct.contrastCustomFile = [1 1 1]; testCase.verifyEqual(testCase.exampleClass.toStruct(testCase.allowedNames, 'custom layers', testCase.varTable), testCase.exampleStruct); diff --git a/tests/testProjectConversion/DSPCBilayerProjectClass.mat b/tests/testProjectConversion/DSPCBilayerProjectClass.mat index a3eda8e7b..18e57cf56 100644 Binary files a/tests/testProjectConversion/DSPCBilayerProjectClass.mat and b/tests/testProjectConversion/DSPCBilayerProjectClass.mat differ diff --git a/tests/testProjectConversion/monolayerVolumeModelProjectClass.mat b/tests/testProjectConversion/monolayerVolumeModelProjectClass.mat index caaf0015e..1a30c79be 100644 Binary files a/tests/testProjectConversion/monolayerVolumeModelProjectClass.mat and b/tests/testProjectConversion/monolayerVolumeModelProjectClass.mat differ