Info
この質問は閉じられています。 編集または回答するには再度開いてください。
How do I load a previously saved mat-flie into a GUI?
1 回表示 (過去 30 日間)
古いコメントを表示
By using the GUIDE function in matlab, a GUI is run that prompts user for double input, and then saved as a .mat file. I want to load this file in another GUI.
Here is the relevant code from the first GUI:
function wallet_Callback(hObject, eventdata, handles)
valid = false; while valid == false myText = get(hObject, 'String'); temp = str2double(myText); if temp <10000.0 && temp > 1.0 playSound('002'); pause(0.5); save('walletSum.mat', 'myText'); valid = true; else disp('Input error.'); playSound('003'); pause(0.5); break end end guidata(hObject, handles);
This works, though clumsy it is. However, when I later want to load the m.file by:
function insert_bet_Callback(hObject, eventdata, handles)
bet = get(hObject, 'String'); % temp2 =load(walletSum___);
temp1 = str2double(bet); %temp2 = str2double(temp2);
if temp2>temp1 && temp1<0 %CheckSum<walletSum
playSound('003');
pause(0.5);
disp('Input error.');
else bet = temp1;
tempSum = temp2-temp1; %Withdraw money
walletSum = num2str(tempSum);
save('walletSum.txt', 'myText')
save('betSize', 'bet')
disp('WARNING: Bet subtracted from wallet.');
end guidata(handles.current_data);
I've put '%' because of the errors, until I would find a solution but I can't, and I can no longer ignore it. I get the "Undefined function or variable "walletSum"." - error. I'm obviously quite new to matlab, so forgive me for my ignorance.
If you could help me find a way so: The walletSum - bet is possible, and saved back into the same file, that would be great.
Thank you.
0 件のコメント
回答 (1 件)
John Petersen
2013 年 1 月 24 日
Instead of
temp2 = load(walletSum___);
try
load walletSum.mat
or try
wS = load(walletSum.mat);
temp2 = wS.myText;
If you can, next time give the exact error that is displayed.
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!