在每个for循环中保存具有动态名称的结构

问题描述 投票:0回答:1

我有一个for循环,其中必须保存具有动态名称的结构。例如

save SubjInfoRisk.mat   SubjInfo

在第二个循环中,我需要保存

save SubjInfoCAD.mat  SubjInfo

为此,我将字符串连接如下:

Group={'CAD','RISK'}
 matflename=strcat('SubjInfo',group{1},'.mat')
 save matflename  subjInfo

但它不起作用。有什么建议吗?

最好

matlab save structure
1个回答
0
投票
save matflename  subjInfo

翻译成

save('matflename','subjInfo')

也就是说,任何看起来不像函数调用的命令实际上都是具有强参数的函数调用。因此,您将保存到名为“matflename”的文件中。相反,做:

save(matflename,'subjInfo')
© www.soinside.com 2019 - 2024. All rights reserved.