# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

# sph2cart

Transform spherical coordinates to Cartesian

## Syntax

• ``[x,y,z] = sph2cart(azimuth,elevation,r)``
example

## Description

example

````[x,y,z] = sph2cart(azimuth,elevation,r)` transforms corresponding elements of the spherical coordinate arrays `azimuth`, `elevation`, and `r` to Cartesian, or xyz, coordinates.```

## Examples

collapse all

Convert the spherical coordinates defined by corresponding entries in the matrices `az`, `el`, and `r` to Cartesian coordinates `x`, `y`, and `z`. These points correspond to the eight vertices of a cube.

```az = [0.7854 0.7854 -0.7854 -0.7854; 2.3562 2.3562 -2.3562 -2.3562] ```
```az = 0.7854 0.7854 -0.7854 -0.7854 2.3562 2.3562 -2.3562 -2.3562 ```
```el = [0.6155 -0.6155 0.6155 -0.6155; 0.6155 -0.6155 0.6155 -0.6155] ```
```el = 0.6155 -0.6155 0.6155 -0.6155 0.6155 -0.6155 0.6155 -0.6155 ```
```r = 1.7321*ones(2,4) ```
```r = 1.7321 1.7321 1.7321 1.7321 1.7321 1.7321 1.7321 1.7321 ```
```[x,y,z] = sph2cart(az,el,r) ```
```x = 1.0000 1.0000 1.0000 1.0000 -1.0000 -1.0000 -1.0000 -1.0000 y = 1.0000 1.0000 -1.0000 -1.0000 1.0000 1.0000 -1.0000 -1.0000 z = 1.0001 -1.0001 1.0001 -1.0001 1.0001 -1.0001 1.0001 -1.0001 ```

## Input Arguments

collapse all

Azimuth angle, specified as a scalar, vector, matrix, or multidimensional array. `azimuth`, `elevation`, and `r` must be the same size, or any of them can be scalar.

`azimuth` is the counterclockwise angle in the x-y plane measured in radians from the positive x-axis.

Data Types: `single` | `double`
Complex Number Support: Yes

Elevation angle, specified as a scalar, vector, matrix, or multidimensional array. `azimuth`, `elevation`, and `r` must be the same size, or any of them can be scalar.

`elevation` is the elevation angle in radians from the x-y plane.

Data Types: `single` | `double`
Complex Number Support: Yes

Radius, specified as a scalar, vector, matrix, or multidimensional array. `azimuth`, `elevation`, and `r` must be the same size, or any of them can be scalar.

The length units of `r` can be arbitrary, and the output arrays `x`, `y`, and `z` use the same units.

Data Types: `single` | `double`
Complex Number Support: Yes

## Output Arguments

collapse all

Cartesian coordinates, returned as arrays.

collapse all

### Tall Array Support

This function fully supports tall arrays. For more information, see Tall Arrays.

### Algorithms

The mapping from spherical coordinates to three-dimensional Cartesian coordinates is

```x = r .* cos(elevation) .* cos(azimuth) y = r .* cos(elevation) .* sin(azimuth) z = r .* sin(elevation)```