Info

This question is closed. Reopen it to edit or answer.

How to plot variables from loaded mfile in gui

1 view (last 30 days)
Tomas
Tomas on 9 Nov 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi, i have school project ,where i want to load data from mfile and then plot some graphs in gui using data from loaded mfile. I tried something like this
"% --- Executes on button press in ImportDat.
function ImportDat_Callback(hObject, eventdata, handles)
% hObject handle to ImportDat (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename pathname]=uigetfile({'*.m'},'Vyber dat'); % zobrazi moznost urcenia mfilu na nacitanie dat
if isequal(filename,0)
disp('User selected Cancel')
else
disp(['User selected ', fullfile(pathname, filename)])
end
fullpathname=[pathname, filename];
text=fileread(fullpathname);
set(handles.text3,'String', fullpathname);
set(handles.ObsahNacitanehoMfilu,'String', text);
data=load([pathname filename]);
guidata(hObject, handles);"
But anytime i chose mfile to load i get error message like this
"User selected C:\Users\Tomas Lojek\Desktop\FEI\IP\skusobny.m
Error using load
Number of columns on line 3 of ASCII file C:\Users\Tomas Lojek\Desktop\FEI\IP\skusobny.m
must be the same as previous lines.
Error in NavrhIP1>ImportDat_Callback (line 172) data=load([pathname filename]);
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in NavrhIP1 (line 43) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)NavrhIP1('ImportDat_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback"
In that mfile i have just for testing this "x=0:0.1:10; y=sin(x); z=[1 2 3 4 5]; v=[10 20 30 40 50];" Can anybody help me please ? Thanks !

Answers (0)

Community Treasure Hunt

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

Start Hunting!