필터 지우기
필터 지우기

Reading data from .m file in Gui

조회 수: 1 (최근 30일)
Niels
Niels 2014년 4월 7일
Hi All,
I have a GUI, where I am to fetch values from another .m file depending on which choice they make in the popupmenu (different kind of ships). So far I get the correct values showed in the GUI window, but the data the program is parsing is not correct. I do not know where they are taken from, definately not my data.
So my question is, how do I assure, that the right values are taken from one .m file are parsed to the next one. Two bites of my script looks like this:
function popupmenu1_Callback(hObject, eventdata, handles) % hObject handle to popupmenu1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu1
switch get(handles.popupmenu1,'Value')
case 1 %Container ship
number = 1;
case 2 %Bulk Carrier
number = 2;
case 3 %ULCC
number = 3;
case 4 %Ro Ro
number = 4;
case 5 %Cruise liner
number = 5;
case 6 %Container feeder
number = 6;
case 7 %Chemical tanker
number= 7;
otherwise
end
%handles.number = number;
[Lpp,B,D,T,Disp,Loa,AeA0,Dmax,z] = Shipdata_module(number);
set(handles.Lpp, 'String',Lpp);
set(handles.B, 'String',B);
set(handles.D, 'String',D);
set(handles.T, 'String',T);
set(handles.Disp, 'String',Disp);
set(handles.Loa, 'String',Loa);
set(handles.AeA0, 'String',AeA0);
set(handles.Dmax, 'String',Dmax);
set(handles.z, 'String',z);
And the other one sending the vaariables away:
function loadship_Callback(hObject, eventdata, handles) % hObject handle to loadship (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
assignin('base','Lpp',handles.Lpp); assignin('base','B',handles.B); assignin('base','D',handles.D); assignin('base','T',handles.T); assignin('base','Disp',handles.Disp); assignin('base','Loa',handles.Loa); assignin('base','AeA0',handles.AeA0); assignin('base','Dmax',handles.Dmax); assignin('base','z',handles.z);
[Vkin,g] = Userinputmodule(handles.Lpp,handles.B,handles.D,handles.T,handles.Vsin,handles.Disp,handles.Loa,handles.z,handles.AeA0,handles.Dmax,handles.route); guidata(hObject, handles); initialize_gui(gcbf, handles, true);
I hope someone can direct me :)
/Niels

답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by