这是我们老师布置的一次作业,设计一个图形用户界面,输入参数计算出各项汽车性能指标,由于本人水平有限,有部分公式未能用代码形式表达出来,望谅解。
解释一下:
1.代码主要分为两个部分,对应两个GUI界面的按钮(图中圈圈);

图1

图2
2.首先,要执行“可编辑文本”里的值必须要在
此条语句下方用变量读取其值,也就是用一个变量表示这个文本框里面的数(本人粗鄙的理解)

3.之后是各种汽车性能指标计算所需要的代码公式
具体解释均在标注里
%以下部分为图1中的计算过程
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
N1=str2double(get(handles.edit1,'String'));%各发动机转速
N2=str2double(get(handles.edit2,'String'));
N3=str2double(get(handles.edit3,'String'));
N4=str2double(get(handles.edit4,'String'));
N5=str2double(get(handles.edit5,'String'));
N6=str2double(get(handles.edit6,'String'));
N7=str2double(get(handles.edit7,'String'));
N8=str2double(get(handles.edit8,'String'));
N9=str2double(get(handles.edit9,'String'));
N10=str2double(get(handles.edit10,'String'));
N11=str2double(get(handles.edit11,'String'));
% T1=str2double(get(handles.edit12,'String'));%各发动机转矩
% T2=str2double(get(handles.edit13,'String'));
% T3=str2double(get(handles.edit14,'String'));
% T4=str2double(get(handles.edit15,'String'));
% T5=str2double(get(handles.edit16,'String'));
% T6=str2double(get(handles.edit17,'String'));
% T7=str2double(get(handles.edit18,'String'));
% T8=str2double(get(handles.edit19,'String'));
% T9=str2double(get(handles.edit20,'String'));
% T10=str2double(get(handles.edit21,'String'));
% T11=str2double(get(handles.edit22,'String'));
%根据1.3的发动机转矩与发动机转速的关系得出以下发动机转矩(此为汽车理论(第五版)余志生 的课后习题1.3中所表述的计算货车发动机转矩的公式)
T1=-19.313+295.27*(N1/1000)-165.44*(N1/1000)^2+40.874*(N1/1000)^3-3.8445*(N1/1000)^4;
T2=-19.313+295.27*(N2/1000)-165.44*(N2

本文记录了一次使用MATLAB构建图形用户界面(GUI)完成汽车性能参数计算的作业体验。博主分享了代码结构,指出GUI中读取文本框数值的方法,并提及未完成的部分,如百公里加速时间和超车时间的计算。虽然部分代码源于他人博客,但博主鼓励交流讨论以共同进步。
最低0.47元/天 解锁文章
3315

被折叠的 条评论
为什么被折叠?



