我的 matlab 脚本中有 2 个函数。这些函数通过*.mat
文件交换数据。在其中一个函数中,我读取了特定文件的数量和其中的数据。后来我处理并将变量存储ggd
在proj1.mat
文件中。如下所示 :
function browse_pushBtn_Callback(hObject, eventdata, handles)
% hObject handle to browse_pushBtn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.directory = uigetdir('C:\temp\');
guidata(hObject,handles);
ggd.directory = handles.directory;
if (ggd.directory)
set(handles.browse_textEdit,'String',handles.directory);
disp2listbox(handles.mainLog_listBox, '1. Searching for GGD Datafile:');
ggd = MyRead(ggd);
disp2listbox(handles.mainLog_listBox, sprintf(' -%d Bilder
gefunden',length(ggd.bilds)));
save proj1 ggd;
else
set(handles.browse_textEdit,'String','Select a directory');
end
第二个功能是:
function start_pushBtn_Callback(hObject, eventdata, handles)
% hObject handle to start_pushBtn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
option = get(handles.mainMenu,'Value');
if (option == 1)
disp2listbox(handles.mainLog_listBox, '2. Calculating the quadratic size..');
fprintf('path is : %s\n', pwd); % did just to check the path (for debugging purpose)
load proj1 ggd;
ggd = MyProcess(ggd);
save proj1 ggd;
disp2listbox(handles.mainLog_listBox, sprintf(' -MySize: %d X %d',ggd.X(1), ggd.Y(2)));
disp2listbox(handles.mainLog_listBox, '3. opening another function...');
% call to another function
elseif (option == 2)
disp2listbox(handles.mainLog_listBox, '2. opening third function...');
% call to third different function
end
有趣的是,当我在 Matlab 工具中运行这两个函数时,它们工作得非常好。后来,我为我的应用程序编译了独立的可执行文件。这个独立的应用程序在第一个功能之前可以正常工作;但是,当我调用第二个函数时,它会proj1.mat
从另一个包含完全不同数据的未知位置加载文件。
不知道导致这种奇怪行为的问题是什么。
我在独立执行时检查了第二个函数中的当前路径(pwd
),发现它与第一个函数中的路径相同。
有任何想法吗 ??