フィルターのクリア

How can I extract fields from a structure and create variables in the MATLAB workspace for example i need to extract every row in the field of position as shown below

20 ビュー (過去 30 日間)
Capturepp.PNG
  2 件のコメント
Walter Roberson
Walter Roberson 2019 年 10 月 1 日
What is an example of the output you would like?
Stephen23
Stephen23 2019 年 10 月 1 日
編集済み: Stephen23 2019 年 10 月 1 日
"...for example i need to extract every row in the field of position as shown below"
Why do you want to do this?
Currently you can trivially access the data in the structure (using basic indexing and fieldnames), so why would you want to make your data access more complex by splitting your data up into many separate variables?

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

回答 (2 件)

Image Analyst
Image Analyst 2019 年 10 月 1 日
Try this:
for k = 1 : length(particle)
% Extract the Position field for this row into a new variable.
thisRow = particle(k).Position;
% Now do something with thisRow....
end

CARLOS RIASCOS
CARLOS RIASCOS 2019 年 10 月 1 日
You can try to understand a structure from the following code, in which several types of data are defined within a structure called s.
s.a = 1;
s.b = {'A','B','C'};
s.c.f = 4;
Then, you can extract from the structure s, an arbitrary data, for example, to extract the constant 1, in your script you can define the following, from the name with which it was saved in the structure, like this:
H = s.a;
Now, in the Workspace a variable called H with the value of 1 is defined.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by