필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

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

조회 수: 1 (최근 30일)
wolss
wolss 2019년 6월 28일
마감: MATLAB Answer Bot 2021년 8월 20일
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
Stephen23
Stephen23 2019년 6월 28일
편집: Stephen23 2019년 6월 28일
"...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?

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by