There is a column vector A, which consists of strring rows. Need to extract symbol numbered j from row numbered i , . How do I solve this problem?
example :
A=["abcd"
“efgh”
“ijklm”],
Need to extract symbol numbered 3 from row numbered 3, i.e. symbol "k"

 Akzeptierte Antwort

Voss
Voss am 27 Feb. 2022

0 Stimmen

A=["abcd";"efgh";"ijklm"]
A = 3×1 string array
"abcd" "efgh" "ijklm"
row_symbol_idx = [3 3];
symbol = extract(A(row_symbol_idx(1)),row_symbol_idx(2))
symbol = "k"

4 Kommentare

roborrr
roborrr am 27 Feb. 2022
Thank you for the answer, but the program gives me the following error: "Undefined function 'extract' for input arguments of type 'string'."
OK. Maybe your MATLAB version is older than extract().
You can try this, which will extract a single character:
A=["abcd";"efgh";"ijklm"];
row_symbol_idx = [3 3];
ch = char(A(row_symbol_idx(1)));
symbol = ch(row_symbol_idx(2))
symbol = 'k'
Or this, which is the same, but it converts that character to a string:
A=["abcd";"efgh";"ijklm"];
row_symbol_idx = [3 3];
ch = char(A(row_symbol_idx(1)));
symbol = string(ch(row_symbol_idx(2)))
symbol = "k"
roborrr
roborrr am 27 Feb. 2022
thank you so much , it was very helpful.
Voss
Voss am 27 Feb. 2022
You're welcome!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 27 Feb. 2022

Kommentiert:

am 27 Feb. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by