Convert a string array to numbers (RGB triplets)

3 ビュー (過去 30 日間)
Ana Egatz-Gomez
Ana Egatz-Gomez 2023 年 4 月 28 日
コメント済み: Ana Egatz-Gomez 2023 年 4 月 28 日
I have the string array named Colores, and I want to convert it to a 7x3 numerical array I can use to pass RGB values to scatter plotting functions. I am stuck here. Can anyone please help?
Colores 7×1 string array
"0 0 0.17241"
"0 0 1"
"0 0 1"
"0 0 1"
"0 0 1"
"1 0.82759 0"
"0 0 1"
"1 0.82759 0"
  2 件のコメント
VBBV
VBBV 2023 年 4 月 28 日
移動済み: VBBV 2023 年 4 月 28 日
Colores = ["0 0 0.17241"; "0 0 1"; "0 0 1"; "0 0 1"; "0 0 1"; "1 0.82759 0"; "0 0 1"; "1 0.82759 0"]
Colores = 8×1 string array
"0 0 0.17241" "0 0 1" "0 0 1" "0 0 1" "0 0 1" "1 0.82759 0" "0 0 1" "1 0.82759 0"
fprintf('%s\n', Colores)
0 0 0.17241 0 0 1 0 0 1 0 0 1 0 0 1 1 0.82759 0 0 0 1 1 0.82759 0
Ana Egatz-Gomez
Ana Egatz-Gomez 2023 年 4 月 28 日
Thank you!

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

採用された回答

Stephen23
Stephen23 2023 年 4 月 28 日
S = ["0 0 0.17241"; "0 0 1"; "0 0 1"; "0 0 1"; "0 0 1"; "1 0.82759 0"; "0 0 1"; "1 0.82759 0"]
S = 8×1 string array
"0 0 0.17241" "0 0 1" "0 0 1" "0 0 1" "0 0 1" "1 0.82759 0" "0 0 1" "1 0.82759 0"
M = double(split(S))
M = 8×3
0 0 0.1724 0 0 1.0000 0 0 1.0000 0 0 1.0000 0 0 1.0000 1.0000 0.8276 0 0 0 1.0000 1.0000 0.8276 0

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by