Main Content

write

Write SOFA file

Since R2023b

    Description

    example

    write(s,filename) writes the data in the object s to a SOFA file specified by filename.

    Examples

    collapse all

    Create a SOFA object following the SimpleFreeFieldHRIR convention.

    s = sofaconvention("SimpleFreeFieldHRIR");

    Generate mock impulse response data to store in the file. Set the number of measurements M to two and set the impulse response length N to 1024. The number of receivers R is two, corresponding to two ears. Use the fir1 function to create arbitrary FIR filters for the impulse response measurements.

    M = 2;
    N = 1024;
    R = 2;
    
    IR = zeros(M,R,N);
    IR(1,:,:) = [fir1(N-1,0.1);fir1(N-1,.2)];
    IR(2,:,:) = [fir1(N-1,0.15);fir1(N-1,.25)];

    Store the measurements in the SOFA object. Modify one of the metadata properties.

    s.Numerator = IR;
    s.Comment = "This SOFA file contains mock FIR data.";

    Write the object to a file named myFile.sofa.

    write(s,"myFile.sofa");

    Input Arguments

    collapse all

    Name of the SOFA file, specified as a string scalar or character vector.

    Data Types: char | string

    Version History

    Introduced in R2023b