matlab - 使用特定文件名 matlab 保存矩阵
问题描述
我正在尝试使用特定文件名保存 2 列矩阵,但我不断生成相同的错误消息:
Error using save
Must be a string scalar or character vector
我的代码如下所示:
CustomName = ['TheDataFrom','_', animalname, '-', animalnumber,'-',num2str(stimNumber), num2str(stimType), '.mat']); % the name I want the file to have, changes with different specimens
TheData(:,1) = codes(index,1);
TheData(:,2) = times(values,1)); %both of these vectors are the same length
save(CustomName, TheData);
我还尝试通过首先使 TheData 成为一个空矩阵来将“TheData”变量变成一个双向量,所以代码看起来像这样,带有额外的行:
CustomName = ['TheDataFrom','_', animalname, '-', animalnumber,'-',num2str(stimNumber), num2str(stimType), '.mat']); % the name I want the file to have, changes with different specimens
TheData = zeros(length(index), 2) %make a matrix of the right number of rows and columns, comes out as class 'double'
TheData(:,1) = codes(index,1); %put data into each column
TheData(:,2) = times(values,1));
save(CustomName, TheData);
我只想用一个特定于标本的名称保存这个矩阵,我不知道为什么我正在做的事情不起作用。请帮忙!
谢谢
解决方案
您需要指定要保存为字符向量的变量的名称,这意味着您实际上不想将变量本身作为save
. 而是创建一个包含要存储的变量名称的字符向量:
save(Customname, 'TheData');
推荐阅读
- javascript - 被 CORS 政策阻止:反应 js 应用程序问题。爱讯
- c# - 使用 .Net Core API 防止缓存
- javascript - 如何在计算器中获取单击按钮的值
- c++ - 二和问题的最有效算法(涉及索引)
- python - 在pandas groupby函数Python中应用最大最小值和最后一个索引
- mongodb - Mongoose 在删除时不返回 HTTP 状态代码 204
- android - 从原生 Android 应用打开渐进式 Web 应用
- c# - 在 C# TestServer 中使用 TestStartup 进行 int 测试抛出 Not Found
- c++ - 使用奇怪重复模板模式 (CRTP) 时计算多维数组的线性索引
- javascript - Only push the object which is not in the array yet