フィルターのクリア

Loading a .mat fil into my gui edit box

6 ビュー (過去 30 日間)
Mikkel
Mikkel 2012 年 7 月 3 日
Hi
Ive made a gui with alot of editboxes, and made a save button that saves the data I've put into the edixboxes, to a .mat fil.
The mat fil is a matrix due to the many edixboxes.
But now I want to make a load button.
load(uigetfile('*.mat','Select the MATLAB code file'));
This is what I have, but it doesn't load my data into the editboxes.. What more do I need to write? I have 40 editboxes.
  1 件のコメント
Rabia Butt
Rabia Butt 2012 年 7 月 26 日
hey mikkel!
would you help me by telling how do you save the data you input in your editbox to a .mat file?????
I would appreciate your help! thanks!

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2012 年 7 月 3 日
I have to make a bunch of assumptions about how you are representing your values.
[filename pathname] = uigetfile('*.mat','Select the MATLAB code file');
L = load( fullfile( pathname, filename ) );
varnames = fieldnames(L);
fieldvals = L.(varnames{1}); %GUESS: you only have 1 variable in .mat
%GUESS: the one variable is a vector of numeric values
%GUESS: you have a vector of edit box handles
%GUESS: and each box is to get the textural representation of one value
for K = 1 : length(fieldvals)
set( YourEdithandles(K), 'String', num2str( fieldvals(K) ) );
end
  6 件のコメント
Mikkel
Mikkel 2012 年 7 月 7 日
I'm a bit lost, when you make the code general, then I don't know what to change. So the biggest help you could do for me is make it specifik for my problem. if we start from what I've made with the two matrix [3x3] and [2x2] which are called Load_soil = [3x3] and Load_dim = [2x2]
If I want to get the number 5 from the load_soil matrix into my editbox 5. What do I write?
Walter Roberson
Walter Roberson 2012 年 7 月 7 日
[filename pathname] = uigetfile('*.mat','Select the MATLAB code file');
L = load( fullfile( pathname, filename ) );
fieldvals = L.Load_soil;
for K = 1 : numel(fieldvals)
set( YourEdithandles(K), 'String', num2str( fieldvals(K) ) );
end

サインインしてコメントする。

その他の回答 (1 件)

Mikkel
Mikkel 2012 年 7 月 7 日
If you wanna see the picture full its on this link: http://postimage.org/image/wxo3v3ic5/full/
I hope this image helps you understand my problem? Because I've done as you said (I think) or atleast as good as I can.
But it just gave me an error as you can see on the picture. Really hop you can help me. :)
  22 件のコメント
Mikkel
Mikkel 2012 年 7 月 9 日
編集済み: Mikkel 2012 年 7 月 9 日
I think I understand you, but what do I type?
NaN -34 NaN NaN NaN NaN NaN NaN NaN NaN
The first line from my matrix looks like this, so if I only take that one, its a vector.
But what do I load?
YourEditHandles5 = [handles.edit1]; <--- I tryed that, but It just gave me the 1,1 = NaN and not the -34
I need something to type infront of it.
like:
YourEditHandles5 = [xxxxxxxx.xxxxxx handles.edit1];
Help
Ive tryed NaN or 0 but nothing helps, it has to be a handle
Mikkel
Mikkel 2012 年 7 月 9 日
This is the error I got
??? Index exceeds matrix dimensions.
Error in ==> boetten>load_Callback at 1500 set( YourEditHandles5(K), 'String', num2str( fieldvals5(K) ) );
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> boetten at 51 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)boetten('load_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by