How do I assign multiple variables the array data from multiple rows in a field

8 ビュー (過去 30 日間)
Mark Sloan
Mark Sloan 2023 年 3 月 15 日
コメント済み: Matt J 2023 年 3 月 15 日
I am new to MATLAB programming and am having trouble even asking the right question. I am trying to assign 6 variables the array data from 6 vertical cells (rows), from a field called "analysis.opt_history.error". When I type this:
A = analysis.opt_history.error
I get the array from the first row (this is OK):
A =
1.068 0.749 0.749 0.737 0.737
However, I also want to retrieve the array data that is in Rows 2 through 6 and assign the values of each cell to B, C, D, E, F separately. I cannot figure out how to do this despite much time reading the community. Thanks!
Mark

採用された回答

Matt J
Matt J 2023 年 3 月 15 日
編集済み: Matt J 2023 年 3 月 15 日
Is this what you mean?
data={1,2,3,4,5,6}'
data = 6×1 cell array
{[1]} {[2]} {[3]} {[4]} {[5]} {[6]}
[A,B,C,D,E,F]=deal(data{:})
A = 1
B = 2
C = 3
D = 4
E = 5
F = 6
  5 件のコメント
Mark Sloan
Mark Sloan 2023 年 3 月 15 日
That works! Thank you so much for your quick help! I'll need to study cell arrays (and what is not a cell array). Many thanks!
Matt J
Matt J 2023 年 3 月 15 日
@Mark Sloan You're welcome, but please Accept-click the answer to indicate that it worked.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by