Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How can I change the field name from a cell of structs1x91?

1 vue (au cours des 30 derniers jours)
wolss
wolss le 28 Juin 2019
Clôturé : MATLAB Answer Bot le 20 Août 2021
Hi, I have a cell of structs constituted by 91 columns, each one contains a matrix and I've loaded this matrices with "load".
Since the matrices are 91, I inserted them into a cell, but Matlab randomly gives to each one a random value (first vector, then vactor 3, then vector, then vector 1 and so on), and so I don't know how to access by a cycle to all the structs.
For this reason I'm asking if it is possible to change the field names given by Matlab in one shot. I can't use the usual notation beacuse in this way I should do 91 iterations, and I have to do these 91 iterations other 7 times.. and so I would spend too much time.
Thank you
  1 commentaire
Stephen23
Stephen23 le 28 Juin 2019
Modifié(e) : Stephen23 le 28 Juin 2019
"...but Matlab randomly gives to each one a random value"
That is very unlikely, MATLAB does not do things randomly (in fact it is extremely difficult to make computers do things randomly). So you should investigate this order (possibly it comes from the filenames or fieldnames, but as you did not give us any information on these, this is just a guess).
...I don't know how to access by a cycle to all the structs."
I doubt that manipulating fieldnames is a good approach: that is what indexing is for.
If you are loading the data in a loop then you can trivially assign the loaded data to an array using indexing (e.g. a cell array or a structure array).
It would help if you clarified some questions about your files:
  • what format are they (e.g. .mat files, text files, etc.) ?
  • If they are .mat files, do they all contain variables with exactly the same names?
  • If they are .mat files, how many variables per file?
  • can you upload some sample files?

Réponses (0)

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by