spectrum
Syntax
Description
specifies options using one or more name-value arguments.h
= spectrum(s
,Name=Value
)
spectrum(___)
with no output arguments plots the power
spectrum.
Examples
Compute Power Spectrum of HRTF Data
Read in a SOFA file containing HRTF measurements.
s = sofaread("ReferenceHRTF.sofa");
Use spectrum
to compute the power spectrum of the HRTF data in the horizontal plane at zero elevation for the first receiver.
[h,f] = spectrum(s);
Call spectrum
with no output arguments to plot the power spectrum of the HRTF data in the horizontal plane for the first receiver.
spectrum(s)
Compute Power Spectrum of Interpolated HRTF Data
Read in a SOFA file containing HRTF measurements.
s = sofaread("ReferenceHRTF.sofa");
Use spectrum
to compute the power spectrum of the HRTF data in the horizontal plane offset by 7 degrees of elevation. See how the returned spectrum is empty because the SOFA file contains no measurements in the specified plane.
h = spectrum(s,Plane="horizontal",PlaneOffsetAngle=7);
size(h)
ans = 1×2
2048 0
Call spectrum
with InterpolateHRTF
set to true
to compute the spectrum using interpolated HRTF measurements corresponding to 100 uniformly-spaced points in the specified plane.
h = spectrum(s,Plane="horizontal",PlaneOffsetAngle=7,InterpolateHRTF=true);
size(h)
ans = 1×2
2048 100
Call spectrum
with no output arguments to plot the computed spectrum.
spectrum(s,Plane="horizontal",PlaneOffsetAngle=7,InterpolateHRTF=true);
Input Arguments
s
— SOFA object
SimpleFreeFieldHRIR
object | SimpleFreeFieldHRSOS
object | SimpleFreeFieldHRTF
object
SOFA object, specified as one of the following objects.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: spectrum(s, Plane="median")
Receiver
— Indices of receivers
1 (default) | vector of positive integers
Indices of the receivers to use for the power spectrum, specified as a vector of positive integers.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
NPoints
— Number of points in spectrum
positive integer
Number of points in the spectrum, specified as a positive integer. For SimpleFreeFieldHRIR
objects, the default value is
max(2048,L)
, where L is
the length of the HRTF impulse responses. For SimpleFreeFieldHRSOS
objects, the default value is 2048.
This argument does not apply to SimpleFreeFieldHRTF
objects.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Plane
— Plane
"horizontal"
(default) | "median"
| "sagittal"
Plane to compute spectrum for, specified as "horizontal"
,
"median"
, or "sagittal"
.
Data Types: char
| string
PlaneOffsetAngle
— Plane offset angle
0 (default) | value in range [-90,90]
Plane offset angle in degrees, specified as a value in the range [-90,90]. This
angle specifies the offset by which the Plane
is shifted.
This argument only applies to the horizontal and sagittal planes. For the horizontal plane, the offset corresponds to the elevation angle. For the sagittal plane, the offset corresponds to the lateral angle.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
AngleTolerance
— Angle tolerance
1 (default) | positive scalar
Angle tolerance in degrees, specified as a positive scalar. The function computes
the spectrum of measurements within the tolerance of the plane specified by
Plane
and PlaneOffsetAngle
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
InterpolateHRTF
— Use interpolated HRTF measurements
false
(default) | true
Use interpolated HRTF measurements, corresponding to 100 uniformly-spaced points
in the specified plane, to compute the power spectrum. Set this argument to
true
if the plane specified by Plane
,
PlaneOffsetAngle
, and AngleTolerance
does
not contain a sufficient number of HRTF measurements. The function uses the bilinear
interpolation method.
Data Types: logical
Output Arguments
h
— Power spectrum
N-by-M-by-R array
Power spectrum computed from the HRTF data, returned as an N-by-M-by-R array, where:
N is the length of the spectrum.
M is the number of selected measurements.
R is the number of selected receivers defined by
Receiver
.
f
— Frequencies
vector of length N
Frequencies in Hz corresponding to the spectrum, returned as a vector of length N, where N is the length of the spectrum.
ang
— Angles
vector
Angles in degrees corresponding to the measurements used to compute the spectrum,
returned as a vector. The interpretation of the angles depends on the specified
Plane
.
For the horizontal plane, the angles correspond to the azimuth.
For the median plane, the angles correspond to the elevation.
For the sagittal plane, the angles correspond to the polar angles.
Version History
Introduced in R2024a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)