在 MATLAB 中加载多个 .mat 文件

发布于 2024-12-16 21:26:55 字数 551 浏览 5 评论 0原文

我有 110 个名为 time1.mat、time2.mat ...、time110.mat 的文件。我想将这些矩阵加载到 MATLAB 工作区中。

我一直使用 load -'ASCII' matrix.mat 加载当前文件夹中的 ASCII 矩阵文件。

所以我尝试这样做,

for i=1:10 
    filename=strcat('time',int2str(i),'.mat');
    load -'ASCII' filename
end

但我收到 MATLAB 错误,因为

??? Error using ==> load
    Unable to read file filename: No such file or directory.
�

当然字符串 filename 似乎被 MATLAB 正确评估为 time1.mat。在第一次迭代中,它在负载线处崩溃。

有什么建议我应该如何做到这一点?

I have 110 files named time1.mat, time2.mat ..., time110.mat. I want to load these matrices into the MATLAB workspace.

I have always used load -'ASCII' matrix.mat to load an ASCII matrix file in the current folder.

So I tried doing

for i=1:10 
    filename=strcat('time',int2str(i),'.mat');
    load -'ASCII' filename
end

But I am getting a MATLAB error as

??? Error using ==> load
    Unable to read file filename: No such file or directory.
�

Of course the string filename seems to be evaluated correctly by MATLAB as time1.mat. in the first iteration where it crashes at the load line.

Any suggestions how I should do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁与争疯 2024-12-23 21:26:55

使用 load(filename, '-ascii')

Use load(filename, '-ascii')

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文