Re: [問題] 在GUI- 要怎宣告sin cos ..等的含式已回收
※ 引述《kelune (kelune)》之銘言:
: function anspushbutton_Callback(hObject, eventdata, handles)
: % hObject handle to anspushbutton (see GCBO)
: % eventdata reserved - to be defined in a future version of MATLAB
: % handles structure with handles and user data (see GUIDATA)
: v0=get(handles.inv,'String');
: ih=get(handles.inl,'String');
: ang=get(handles.ina,'String');
: ti=get(handles.inti,'String');
: g=9.8;
: tt=v0*sin(ang)/g; % time to reach the max height
: ^^^^^^^^
: ??? 如何宣告!?
: ==========================================================
: 在pushbutton下宣告一些運算式 即 按下button 他會將輸入的input作些運算
: ??? Undefined function or method 'sin' for input arguments of type 'char'.
: Error in ==> l9>anspushbutton_Callback at 200
: tt=v0*sin(ang)/g; % time to reach the max height
: 試過用char
: "There is no 'char' property in the 'uicontrol' class."
: 要如何解!! 感覺好亂阿!! 請幫忙一下...
: 感謝!!
ang的class為string....轉換一下即可
不需要宣告sin
v0=str2num(get(handles.inv,'String'));
ih=str2num(get(handles.inl,'String'));
ang=str2num(get(handles.ina,'String'));
ti=str2num(get(handles.inti,'String'));
g=9.8;
tt=v0*sin(ang)/g; % time to reach the max height
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.122.23
※ 編輯: zzs2005 來自: 140.123.122.23 (12/12 00:12)
推
12/12 09:43, , 1F
12/12 09:43, 1F
討論串 (同標題文章)