필터 지우기
필터 지우기

Make an iucontrol edit box into a number able to be done math on.

조회 수: 2 (최근 30일)
Philosophaie
Philosophaie 2016년 4월 29일
댓글: Adam 2016년 4월 29일
"lat" should be a double and should be able to be subtracted from 90. How do I make "lat" a double and able to be done math on?
lat = uicontrol('Style','edit','String','0','position',[250 630 100 20],'Callback',(@h_lat));
uicontrol('Style','pushbutton','String','Evaluate','Position',[130,550,100,50],'Callback',{@Evaluate},'BackgroundColor','green');
function h_lat(hObject, eventdata, handles)%#ok
lat = str2double(get(hObject,'String'));
handles = guidata(hObject);
guidata(hObject, setfield(handles,'lat',lat));%#ok
function Evaluate(hObject, eventdata, handles)
handles = guidata(hObject);
lat = handles.lat;
disp(lat);
Theta=(90-lat)*pi/180;
Output:
UIControl (0) with properties:
Style: 'edit'
String: '0'
BackgroundColor: [0.9400 0.9400 0.9400]
Callback: @h_lat
Value: 0
Position: [250 630 100 20]
Units: 'pixels'
Show all properties
Undefined function 'minus' for input arguments of type 'matlab.ui.control.UIControl'.
Error in MagneticFieldFromLonLat>Evaluate (line 64)
Theta=(90-lat)*pi/180;
Error while evaluating UIControl Callback
  댓글 수: 3
Philosophaie
Philosophaie 2016년 4월 29일
Normally this given as "lat" as a double and you can do math on it. Why is it not in this case?
Adam
Adam 2016년 4월 29일
lat = uicontrol('Style','edit','String...
Name that something else for a start.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by