how to load variables in the workspace

9 ビュー (過去 30 日間)
Roser Torrent
Roser Torrent 2012 年 7 月 6 日
Hi,
I'm trying to load the variables of a -mat file chosen from a directory and I don't know what I do wrong.
My code is:
[nom, ruta] = uigetfile('*.mat', 'Obrir arxiu');
if isequal (nom,0) %per si prenem cancelar, i no escollim cap arxiu
disp('Has seleccionat Cancel·lar')
else
disp(['Has seleccionat:', fullfile(ruta, nom)])
end
uiimport
I want to program in my file.m, more o less the same function than Import Wizard does, i.e. load all my variables from the .mat file chosen, in my case 'A', 'Length' 'Tinternal' and 'Tstart'.
What do I have to do?
Thanks,

採用された回答

TAB
TAB 2012 年 7 月 6 日
編集済み: TAB 2012 年 7 月 9 日
If you are loading mat file from m-script
load('YourMatFileWithFullPath.mat');
And, If you are loading mat file from function
evalin('base',['load(''' 'YourMatFileWithFullPath.mat' ''')'])
See
>> doc load

その他の回答 (2 件)

Arthur
Arthur 2012 年 7 月 6 日
編集済み: Arthur 2012 年 7 月 6 日
You can read the mat file with
data = open(fullfile(ruta,nom));
the contents of your file will be stored in struct "data" on the workspace (e.g. data.A, data.Length, data.Tinernal, data.Tstart)

Roser Torrent
Roser Torrent 2012 年 7 月 6 日
Thanks Arthur,
I put your code but I can't see the variables, in that case 'data', or 'A', 'Length', 'Tinterval' and 'Tstart' in my workspace window like Import Data Wizard does.
I would like to do the same than "Import Data Wizard" but without use it, i.e. manually,
Can you help me, please?
Roser

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by