can not load mat file correctly
2 ビュー (過去 30 日間)
古いコメントを表示
How to make the function load_dataset below return x value of 2 ?
Thanks
S
>>clear all;
>>x=2;y=4;
>>save('test.mat');
>>x = load_dataset('test.mat','x');
>>x
x =
x
----
function dataset = load_dataset(cfmat,dataset)
try
load(cfmat,deblank(dataset));
catch
dataset=[];
end
0 件のコメント
回答 (2 件)
Image Analyst
2012 年 7 月 31 日
Try something like this (untested):
function storedDataset = load_dataset(cfmat, dataset)
try
storedStructure = load(cfmat);
% Check to see if the requested field exists in the structure.
tf = isfield(storedStructure, dataset)
if tf
% The field exists. Use dynamic fieldname to extract it.
storedDataset = storedStructure.(dataset);
else
storedDataset = [];
end
catch ME
warningMessage = sprintf('%s\n', ME.message);
fprintf('%s\n', warningMessage);
uiwait(warndlg(warningMessage));
storedDataset =[];
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Tables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!