mixedUnits
単位を単位の合計に分割
説明
例
数量を単位の組み合わせに分割
mixedUnits
を使用して、8000
秒を時間、分、秒の組み合わせに分割します。結果は、2 時間 13 分 20 秒です。
u = symunit; t = 8000*u.s; tunits = [u.hour u.minute u.second]; tSplit = mixedUnits(t,tunits)
tSplit = [ 2, 13, 20]
compose
を使用して、表示される出力をカスタマイズします。
compose("%d hours + %d minutes + %.1f seconds", double(tSplit))
ans = "2 hours + 13 minutes + 20.0 seconds"
地理座標 15.352°
を度 (°)、分 (')、および秒 ('') に変換します。結果は 15° 21' 36/5'' です。
gCoord = 15.352*u.degree; gUnits = [u.degree u.arcmin u.arcsec]; gCoordSplit = mixedUnits(gCoord,gUnits)
gCoordSplit = [ 15, 21, 36/5]
double
を使用して、結果をシンボリックから浮動小数点数に変換します。
gCoordDbl = double(gCoordSplit)
gCoordDbl = 15.0000 21.0000 7.2000
分割された単位を合計し、結果を度に書き換えることによって元の座標を再構成します。mixedUnits
は、数値近似ではなくシンボリック厳密解の結果を返します。詳細は、数値演算またはシンボリック演算の選択を参照してください。
gOrig = sum(gCoordSplit.*gUnits); gOrig = rewrite(gOrig,u.degree)
gOrig = (1919/125)*[deg]
入力引数
バージョン履歴
R2018a で導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
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)