Merge multiple cells into one cell array

6 visualizzazioni (ultimi 30 giorni)
Morin De Jesus
Morin De Jesus il 12 Apr 2024
Modificato: Chunru il 12 Apr 2024
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.

Risposte (1)

Chunru
Chunru il 12 Apr 2024
Modificato: Chunru il 12 Apr 2024
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""

Categorie

Scopri di più su Data Types in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by