【发布时间】:2016-07-04 19:12:16
【问题描述】:
我有几个数据集,称为 '51.raw' '52.raw'... 直到 '69.raw' 在我的代码中运行这些数据集后,这些数据集的大小从 375x91x223 变为具有不同 y 的大小-尺寸(即“51.raw”输出:375x45x223;“52.raw”输出:375x50x223,...每个数据集不同)。
我想稍后使用此信息保存“.raw”文件名(即“51_375x45x223.raw”),并且还想使用新的数据集大小在我的代码中重新调整数据集。我已尝试这样做但需要帮助:
for k=51:69
data=reshape(data,[375 91 223]); % from earlier in the code after importing data
% then executes code with dimensions of 'data' chaging to 375x45x223, ...
length=size(data); dimensions.([num2str(k)]) = length; %save size in 'dimensions'.
path=['C:\Example\'];
name= sprintf('%d.raw',k);
write([path name], data);
% 'write' is a function to save the dat in specified path and name (value of k). I don't know how to add the size of the dataset to the name.
稍后我想为这次迭代重塑数据集“数据”,并使用新的 y 维度值进行重塑。
i.e. data=reshape(data,[375 new y-dimension 223]);
您的帮助将不胜感激。谢谢。
【问题讨论】:
-
为什么不将尺寸inside保存在标题行中?这比尝试使用文件名来传达有关其内容的信息要好得多
-
感谢您的评论 Suever,输出保存为 .raw 文件。然后为了在其他软件(ImageJ)中打开它,如果其他人想做它会更方便。另外,您提到的也是我的想法,但我被要求将其更改为文件名,但我不确定如何。
标签: matlab loops rename filenames