Matlab从文本到结构

Matlab从文本到结构,matlab,matlab-struct,Matlab,Matlab Struct,我有一个大(工作)结构的m文件。经过大量的努力,我找到了一种用fprint等更新一些结构的方法。我保存了文件,保存后一切看起来都很好,但我想在函数中进一步使用结构 我可以通过 运行(文件名) Actor=ans 但它并不总是有效,而且似乎是一种不好的方法。。如果我写: Actor=IndataActor%indatafile的名称为IndataActor。。 它工作得很好(演员得到了结构) 但是我想使用变量“FileName” Actor=FileName Actor刚刚得到文件名的名称(Act

我有一个大(工作)结构的m文件。经过大量的努力,我找到了一种用fprint等更新一些结构的方法。我保存了文件,保存后一切看起来都很好,但我想在函数中进一步使用结构

我可以通过 运行(文件名) Actor=ans

但它并不总是有效,而且似乎是一种不好的方法。。如果我写: Actor=IndataActor%indatafile的名称为IndataActor。。 它工作得很好(演员得到了结构) 但是我想使用变量“FileName” Actor=FileName

Actor刚刚得到文件名的名称(Actor='IndataActor')


有什么建议吗?

结构保存在一个m文件中(作为函数)


然后,我创建了一个GUI(带指南),用于在结构中添加和更改数据。因此,我读入文件并使用几个不同的fprint命令对文件进行更改。struct也保存在已经处理的m文件中。现在我不知道将结构赋值给变量的最佳方法

您是说您使用fprint生成m文件吗?坏习惯。m文件应该是由人类编写的代码。如果要保存数据,请先在内存中构建数据,然后再保存()。不,我用fprint在m文件的结构中做了几处更改。。m文件被保存了,一切正常,但是我现在想把struct赋值给一个变量,我假设struct是指MATLAB数据类型struct。这样的结构不会随fprint而改变。所以我想你必须展示一些代码,以便人们理解你想要实现的目标。有人有什么建议吗?
function [ Actor ] = IndataActorsLund3

%Actor 1
Actor{1}.Name='Räddningstjänsten Syd';
Actor{1}.ExpertNames={'Saknas?'};
Actor{1}.Units={'Saknas?'};
Actor{1}.Titles={'Saknas?'};
Actor{1}.NbrGoals=5;
Actor{1}.Goals={'Trygghet för medborgare', 'Bränder och andra olyckor ska minska','Öka kunskapen angående olyckshantering och riskmedvetenheten', 'Påbörja insats inom 10 minture i 90% av prioriterade olyckor', 'Bryta negativ trend vid insats inom 15min'};
Actor{1}.NbrActivities=6;
Actor{1}.Activities={'Tillsyn, remishantering','Informationsinsatser', 'Internutbildning', 'Externutbildning', 'Skadeavhjälpande insats', 'Olycksutredning','','','',''}; 
Actor{1}.MatrixActGoals=[...
3   4   3   4   3;
5   3   4   2   2;
3   3   1   4   5;
4   3   4   2   2;
5   1   1   5   5;
3   3   2   3   3];
Actor{1}.NbrInfluencingFlows=1;
Actor{1}.InfFlowType(1)=19;
Actor{1}.InfFlowMatrix{1}=[...
0   0   0   0   0   0   0;
0   0   0   0   0   0   0;
0   0   0   0   0   0   0;
0   0   0   0   0.4 0.6 1;
0   0   0   0   0.2 0.5 1;
0   0   0   0   0   0   0];
Actor{1}.NbrDependentFlows=4;
Actor{1}.DepFlowType(1)=1;
Actor{1}.DepFlowMatrix{1}=[...
0   0   0   0   0   0   0;
0   0   0   0   0   0   0;
0   0   0   0   0   0   0;
0   0   0   0.1 0.3 0.5 0.7;
0   0   0   0.6 0.8 0.9 1;
0   0   0   0   0   0   0];
.... (and about 1000 more rows)
end