From: Zia on
Hello Ppl,

I have a stupid question, but hope i will get some help on that.

I am trying to make a stand alone exe. In my model i have run a simulink exe and the result i get is in .mat. Now i want to write those results in Excel, using a GUI push button. I have written the following code for pushbutton call back:

function writexls_Callback(hObject, eventdata, handles)
% hObject handle to writexls (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if ~isdeployed
sp=which('DAE1out.mat');
else
sp=[ctfroot,'\work\adm1_phsolv\DAE1out.mat'];
end

load (sp);


if ~isdeployed
rp=which('Results.xls');
else
rp=[ctfroot,'\work\adm1_phsolv\Results.xls'];
end
xlswrite(rp, rt_DAE1out, 'Digester_Outputs', 'B2:AZ4002');

But when i compile my project using MCR and run it, i get the following error:

??? Undefined function or method 'MT' for input arguments of type
'struct'.
Error in ==>
guidemfile>@(hObject,eventdata)MT_Energy('writexls_Callback',hObject,eventdata,g
uidata(hObject))
??? Error while evaluating uicontrol Callback

Can anybody help me out, how i can correct it. Hope to have some suggestion soon.
Thanks a lot in advance.

Regards!
From: Zia on
Hello Pll,

Regarding the above problem. The callback is working but not in a way it should work. When i run the the exe and run my model it works fine and saves the results in mat format. If i try to write the results immediately after that i get the following error:

??? Undefined function or method 'MT_Energy' for input arguments of type
'struct'.

Error in ==>
guidemfile>@(hObject,eventdata)MT_Energy('writexls_Callback',hObject,eventdata,g
uidata(hObject))



??? Error while evaluating uicontrol Callback

But if i close the exe and runs it again and then press the push button for writing the mat into excel it works fine(without running the model gain). Can anybody give me advice how can i overcome this problem.

Thanks in advance.

Regards!