フィルターのクリア

How do I extract the ith string from a structure that contains i=1:n strings?

4 ビュー (過去 30 日間)
Kevin Johnson
Kevin Johnson 2022 年 3 月 29 日
回答済み: Kevin Johnson 2022 年 3 月 29 日
I have a structure A.x which contains multiple short strings. (Each string is a date, i.e. '2013-05-15').
If I query as follows, just the first string is returned:
string1=A.x;
However, if I query as follows, I get the first two strings:
[string1,string2]=A.x;
and so forth. I want to extract each string sequentially to store elsewhere, but I can't figure out how to index the structure.
A.x(1,:) doesn't work, A.x{1,:} doesn't work. Multiple strings are being stored in there but apparently as neither an array nor a cell. Or if it is an array, I'm using incorrect indices.
I presume there is some way instead to designate the left hand term such that it assigns the output from the right hand term into separate variables?
Thanks,
Kevin
  1 件のコメント
Rik
Rik 2022 年 3 月 29 日
Why do you want to use numbered variables? It looks like you already have an array you can index: A(n).x

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

採用された回答

Kevin Johnson
Kevin Johnson 2022 年 3 月 29 日
OK, that answers my question. I was putting the index in the wrong place, after the x rather than after the A.
Thanks

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by