how to load the data from strut

I want to load the data which can be accessed by
VarName = Cell1.cyc++++.v()
where ++++ indicates the number like
0000, 0100, 0200, 0300,......1000,1100, ....8000, 8100, 8200.
I want to create a matrix from it, where it will contain the only 1st and last element of v() for all cyc++++ (0000 to 8200)
so how can I do it without loading each file one by one?
please help.....Thanking in advance.

4 commentaires

Walter Roberson
Walter Roberson le 14 Oct 2019
Are these in different files, or already in one struct ?
KUNAL PATIL
KUNAL PATIL le 14 Oct 2019
struct Cell1 contains cyc++++ (0000 to 8200), then each cyc++++ contains Ch1, Cd1, Q1 as struct and then each Ch1 contains v (3371 by 1) matrix, t (3371 by 1) matrix, I (3371 by 1) matrix
so it is Cell 1---> cyc++++--->Ch1--->v()
KUNAL PATIL
KUNAL PATIL le 14 Oct 2019
sorry .... it is
VarName = Cell1.cyc++++.Ch1.v()
Stephen23
Stephen23 le 15 Oct 2019
Modifié(e) : Stephen23 le 15 Oct 2019
The best solution is to redesign your data so that you are not forcing meta-data into fieldnames.
Forcing meta-data into fieldnames is one way that beginners force themselves into writing slow, complex, obfuscated, buggy code (exactly as you are finding out now). Your code would be much simpler if you stored the meta-data in the variables rather than in the fieldnames.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 14 Oct 2019

0 votes

In the case where it is already loaded into Cell1 then
output_matrix = [structfun(@(S) S.V(1), Cell1(:)), structfun(@(S) S.V(end), Cell1(:))];

2 commentaires

KUNAL PATIL
KUNAL PATIL le 14 Oct 2019
Sorry ....there is some correction in question
it is
VarName = Cell1.cyc++++.Ch1.v()
output_matrix = [structfun(@(S) S.Ch1.v(1), Cell1(:)), structfun(@(S) S.Ch1.v(end), Cell1(:))];
provided that your Ch1 are scalar structures.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Develop Apps Using App Designer dans Centre d'aide et File Exchange

Tags

Modifié(e) :

le 15 Oct 2019

Community Treasure Hunt

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

Start Hunting!

Translated by