# Merge multiple cells into one cell array

16 ビュー (過去 30 日間)
Morin De Jesus 2024 年 4 月 12 日

I have a three different cell arrays for my DMS (degree, minute, second). I want to combine it into one cell into the DMS format (degree°minute'second"). The second(") data is a decimal number while degree and minutes are integers.
I have a data of like this:
Degrees (19x1) = 128
128 ......
Minutes (19x1) = 34
32....
Seconds (19x1)= 14.651
40.654
How can I combine this three cell arrays into a form such that:
128°34'14.651"
128°32'40.654"
this is what I want to be the result.

サインインしてコメントする。

### 回答 (1 件)

Chunru 2024 年 4 月 12 日

n = 3;
Degrees = randi([0 359], [n, 1])
Degrees = 3x1
146 169 193
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Minutes = randi([0 59], [n, 1])
Minutes = 3x1
27 55 47
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Seconds = rand([n, 1])*60
Seconds = 3x1
34.2840 39.6742 12.0341
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
s = compose("%d%c%d%c%.4f%c", Degrees, char(176), Minutes, "'", Seconds, '"')
s = 3x1 string array
"146°27'34.2840"" "169°55'39.6742"" "193°47'12.0341""

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeImage Quality についてさらに検索

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by