Main Content


Validate SOFA data

Since R2023b



    validate(s) validates the SOFA data to ensure that property values and dimensions are consistent. The function throws an error if there are any validation issues.


    collapse all

    Create a SOFA object following the SimpleFreeFieldHRIR convention. Populate the Numerator property with mock impulse response data containing two receivers, 1000 measurements, and an impulse response length of 256.

    s = sofaconvention("SimpleFreeFieldHRIR");
    s.Numerator = zeros(1000,2,256);

    Populate the SourcePosition property with mock positional data containing source positions for 100 measurements.

    s.SourcePosition = zeros(100,3);

    Call validate on the SOFA object. The function throws an error because the number of measurements in the positional data is inconsistent with the impulse response data.

    Error using audio.sofa.internal.BaseSOFA/checkOneOrVal
    Dimension 1 of SourcePosition must be equal to either one or the number of measurements, 1000.
    Error in audio.sofa.internal.FreeFieldBase/validate (line 242)
    Error in audio.sofa.internal.SimpleFreeFieldBase/validate (line 50)

    Fix the inconsistency by populating SourcePosition with mock data for 1000 measurements. Call validate again to see that it runs with no errors.

    s.SourcePosition = zeros(1000,3);

    Input Arguments

    collapse all

    Version History

    Introduced in R2023b