how to generate structure member values with only one index data of parent structure .

how to generate structure member values with only one index data of parent structure .
struct.member.values(1500,1) from this structure need only struct.member.values(200,1)

2 Comments

What size is badly-named STRUCT?
What size is MEMBER?
member is nested structure with 10 fields , each field values size is (1500,1)

Sign in to comment.

 Accepted Answer

In lieu of your actually answering my questions here I will presume that both badly-named STRUCT and MEMBER are scalar structures, and that given your comment here MEMBER has multiple fields from which you want to extract one value from element (200,1).
S.member = cell2struct(num2cell(rand(1500,1,10),1:2),"val"+(1:10),3) % fake data
S = struct with fields:
member: [1×1 struct]
S.member
ans = struct with fields:
val1: [1500×1 double] val2: [1500×1 double] val3: [1500×1 double] val4: [1500×1 double] val5: [1500×1 double] val6: [1500×1 double] val7: [1500×1 double] val8: [1500×1 double] val9: [1500×1 double] val10: [1500×1 double]
You can extract element (200,1) from each field of MEMBER as follows:
V = structfun(@(a)a(200,1),S.member)
V = 10×1
0.2747 0.5518 0.9667 0.0910 0.7807 0.9588 0.1248 0.7697 0.1378 0.0447

4 Comments

Thank you for reply .
sorry stephen for mentioning now , each struct member are not scalar structures they are of size (1500,256).
"sorry stephen for mentioning now , each struct member are not scalar structures they are of size (1500,256)."
That is exactly why I asked you this question yesterday, which you did not answer.
So as far as I understand, you have a scalar badly-named STRUCT which contains one field MEMBER. Apparently MEMBER is a structure which has size 1500x265, and MEMBER has ten fields, each of which contains a 1500x1 numeric array. This gives 1500*265*10 separate numeric arrays.
However I am not sure that is strictly correct, so please upload some sample data in a mat file by clicking the paperclip button. This does not need to be all of your original data, it just needs to have exactly the same arrangment.
couldn't able upload any data , due to some reasons
"couldn't able upload any data , due to some reasons "
You do not need to upload your private data, just some random values that are stored in exactly the same way.

Sign in to comment.

More Answers (0)

Categories

Asked:

on 27 Jul 2023

Commented:

on 28 Jul 2023

Community Treasure Hunt

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

Start Hunting!