MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   使用加载命令在Matlab中打开.mat文件时出错 (https://www.labfans.com/bbs/showthread.php?t=24047)

poster 2019-12-10 20:48

使用加载命令在Matlab中打开.mat文件时出错
 
这是我的代码的一部分,我在其中输入.mat文件的名称,该文件与我的代码位于同一文件夹中。但是,它无法识别文件名并给出错误:

“ ???使用==>加载时出错

无法读取文件“ q.mat”:没有这样的文件或目录。”

q_type=input('Do you want to use q from "A", "B" or from a saved .mat file? Enter the exact name: ','s'); q_type=mat2str([q_type'.mat']) load(q_type) 但是,如果我按如下所示直接在命令窗口中使用load命令,则它不会出现错误并加载文件:

load('q_A.mat')

为什么会这样?



[B]回答:[/B]

这是一个使用模式对话框的更人性化的解决方案:

[fileName pathName] = uigetfile({'*.mat' 'MAT-files (*.mat)'}, 'Load Data', '.'); if pathName == 0, error('No file selected'), end load( fullfile(pathName,fileName) ) 随时根据需要对其进行自定义。



[url=https://stackoverflow.com/questions/4007011]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 23:16

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.