Loading a .mat fil into my gui edit box
显示 更早的评论
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
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!
采纳的回答
更多回答(1 个)
Mikkel
2012-7-7
0 个投票
22 个评论
Walter Roberson
2012-7-8
Unfortunately my system is claiming it cannot find postimage.org even though I can google it. Anyhow, could you post the image somewhere else?
Walter Roberson
2012-7-8
YourEditHandles = [handles.editbox1, handles.editbox2, handles.editbox3, handles.editbox4, handles.editbox5, handles.editbox6, handles.editbox7, handles.editbox8, handles.editbox9];
And if your actual handle names involve Editbox instead of editbox then use whatever you have, in order, so that the 5th entry in the vector corresponds to your "edit box 5"
Mikkel
2012-7-8
Walter Roberson
2012-7-8
Change YourEdithandles to YourEditHandles in the set()
Walter Roberson
2012-7-8
for K = 1 : numel(fieldsvals2)
set( YourEditHandles2(K), 'String', num2str( fieldvals2(K) ) );
end
Mikkel
2012-7-8
Walter Roberson
2012-7-8
How do you initialize YourEditHandles5 ?
You only spoke before about having two sets of edit boxes, not five or more sets ?
Mikkel
2012-7-8
Walter Roberson
2012-7-8
Put a breakpoint at that line, and run the code. When the line is reached, at the command prompt, give the commands
size(YourEditHandles5)
ishandle(YourEditHandles5)
K
size(fieldvals5)
and let us know what it shows.
Also please show the code that constructs fieldvals5 and YourEditHandles5
Walter Roberson
2012-7-9
I do not presently have access to MATLAB. I am trying to decide which new computer to buy, after which I will need to order a copy of MATLAB.
Mikkel
2012-7-9
Walter Roberson
2012-7-9
What do you want to put there?
if isnan(fieldvals(K))
set( YourEditHandles(K), 'String', {''} ); %or to suit
else
set( YourEditHandles(K), 'String', num2str(fieldvals(K)) );
end
Walter Roberson
2012-7-9
An edit box has to have something even if that something is the empty string.
The code structure I show just above would detect NaN in the input matrix and make it show as the empty string in the empty box.
Mikkel
2012-7-9
Walter Roberson
2012-7-9
Use a vector, not a matrix. Especially not a matrix that cannot decide whether it is one entry per row or 7 entries per row.
Mikkel
2012-7-9
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
