How to insert cell array into a workspace structure?
Show older comments
Dear All, I have quite an unusual problem that I can't solve. After trying to solve it myself for a while I think I need some help. So here it goes...
My Workspace is populated with structure with unique names and several fields
whos
Name Size Bytes Class Attributes
john_doe_155 1x1 2677 struct
jane_doe_179 1x1 2895 struct
.
.
within each structure there are nested structure for rawData(raw) and processedData (proc) such that;
john_doe_155
struct with fields:
procData: [1×1 struct]
rawData: [1×1 struct]
Each set of rawData and procData contains matrix of variables. At this point in time I have fitted a model to a set off raw data. In order to make my analysis accessible to future users, I have created a temporary cell array (tempFitData) that contains few bits of the information such that ....
tempFitData = 1×5 cell array;
Now I need to insert this tempFitData into the procData structure so that in future everyone can access them. At the moment if I command;
john_doe_155.procData.fitData = tempFitData;
I get exactly what I am looking for.
john_doe_155.procData
struct with fields:
time: [6×1 double]
fitData: {1×5 cell}
However I have literally 1000's of these entry in my workspace to go through and I can not do them all individually by hand.Is there any way to automate the whole process?
Unfortunately I have to return the data set in exactly the same way so I have tried using the eval function without any success. Any help will be much appreciated.
1 Comment
"However I have literally 1000's of these entry in my workspace to go through and I can not do them all individually by hand.Is there any way to automate the whole process?"
Yes. Write better code that does not create 1000's of variables in the workspace.
(note: "better" in the sense that the code is neater, less buggy, less complex, more secure, more efficient, and easier to debug.)
Accepted Answer
More Answers (1)
Stephen23
on 30 Nov 2017
0 votes
Did you forget to accept an answer?
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!