Matlab report generator, problem with gui

10 views (last 30 days)
Hey together,
I have created a report with the report generator. Now i have a script where i run this report. everything works fine.
When i open this script via a button in my GUI, matlab wont find the variables.
i had saved the results in a .mat file and load the variables in the workspace in the script where the report is called.
I have tried to get the variables in the report from .mat file direct, instead of "from workspace" but nothing changed.
I dont know how i can fix it, and why the error comes?? can anybody help me? I hope you understand what i mean, thanks for helping!

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 20 Aug 2012
%to get the variables don't use
load File
% instead use
data=load('File')
% if your FileName mat file contains for example the variables x y and z then you can get them from a structure variable File:
x=data.x
y=data.y
z=data.z

More Answers (2)

Andreas
Andreas on 20 Aug 2012
hey,
thanks for your answer but it didnt work. MATLAB still says the variables are not in the workspace.
ive made a new gui, with only a button. and add folowing code
% --- Executes just before testinggg is made visible.
function testinggg_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
c_mat=[1 2; 3 4];
a=1;
b=13;
save 'test_mat' c_mat a b;
guidata(hObject, handles);
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
data=load('test_mat')
a=data.a;
b=data.b;
c_mat=data.c_mat;
report test_rep -fpdf
In the report i have 2x Insert variable, a and c_mat asnd 1 evaluate MATLAB expression with following code
fprintf('\n a test % 2.3f',a);
fprintf('\n c_mat testt %1.3f ',c_mat(1));
Matlab wont find the variables! "a" not found in workspace. "c_mat" not found in workspace.
thanks for help!

Andreas
Andreas on 20 Aug 2012
ahh i get it now^^
i understand u wrong i think.
now i have loaded the variables with data=load('datas'); in my evaluate MATLAB expression!
thanks now it works fine

Categories

Find more on Scripts in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!