⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 new2.m

📁 现代控制原理中线性时不变系统分析与设计软件的MATLAB GUI设计M文件
💻 M
📖 第 1 页 / 共 2 页
字号:
% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end% --- Executes on button press in observe_pb.function observe_pb_Callback(hObject, eventdata, handles)A=str2num(get(handles.amatrix2,'string'));B=str2num(get(handles.bmatrix2,'string'));C=str2num(get(handles.cmatrix2,'string'));D=0;N=size(A);n=N(1);ob=obsv(A,C);rob=rank(ob);if rob==n    set(handles.result_o,'string','系统是可观的')elseif rob~=n    set(handles.result_o,'string','系统不可观')end  % hObject    handle to observe_pb (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)function result_o_Callback(hObject, eventdata, handles)% hObject    handle to result_o (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of result_o as text%        str2double(get(hObject,'String')) returns contents of result_o as a double% --- Executes during object creation, after setting all properties.function result_o_CreateFcn(hObject, eventdata, handles)% hObject    handle to result_o (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end% --- Executes on button press in impulse_pb2.function impulse_pb2_Callback(hObject, eventdata, handles)a=str2num(get(handles.amatrix2,'string'));b=str2num(get(handles.bmatrix2,'string'));c=str2num(get(handles.cmatrix2,'string'));d=str2num(get(handles.dmatrix2,'string'));sys=ss(a,b,c,0);impulse(handles.xiangying,sys);% hObject    handle to impulse_pb2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on button press in step_pb2.function step_pb2_Callback(hObject, eventdata, handles)a=str2num(get(handles.amatrix2,'string'));b=str2num(get(handles.bmatrix2,'string'));c=str2num(get(handles.cmatrix2,'string'));d=str2num(get(handles.dmatrix2,'string'));sys=ss(a,b,c,0);step(handles.xiangying,sys);% hObject    handle to step_pb2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of step_pb2if (get(handles.step_pb2,'Value'))==(get(handles.step_pb2,'Max'))    new('step_pb_Callback',hObject,eventdata,guidata(hObject))elseif (get(handles.impulse_pb2,'Value'))==(get(handles.impulse_pb2,'Max'))    new('impulse_pb_Callback',hObject,eventdata,guidata(hObject))elseif (get(handles.bode2_pb,'Value'))==(get(handles.bode2_pb,'Max'))    new('bode_pb_Callback',hObject,eventdata,guidata(hObject))elseend% --- Executes on button press in bode_pb.function bode_pb_Callback(hObject, eventdata, handles)num=str2num(get(handles.num,'string'));den=str2num(get(handles.den,'string'));sys=tf(num,den);bode(handles.bodeplot,sys);if (get(handles.Grid,'Value'))==(get(handles.Grid,'Max'))    grid on;else    grid off;endif (get(handles.Legend,'Value'))==(get(handles.Legend,'Max'))    legend('toggle');else    legend('off');end% hObject    handle to bode_pb (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on slider movement.function signalamp_Callback(hObject, eventdata, handles)handles.signalamp=get(hObject,'Value');set(handles.signalvalue,'String',num2str(handles.signalamp));if (get(handles.step_pb,'Value'))==(get(handles.step_pb,'Max'))    new('step_pb_Callback',hObject,eventdata,guidata(hObject))elseif (get(handles.impulse_pb,'Value'))==(get(handles.impulse_pb,'Max'))    new('impulse_pb_Callback',hObject,eventdata,guidata(hObject))elseif (get(handles.bode_pb,'Value'))==(get(handles.bode_pb,'Max'))    new('bode_pb_Callback',hObject,eventdata,guidata(hObject))elseend% hObject    handle to signalamp (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider% --- Executes during object creation, after setting all properties.function signalamp_CreateFcn(hObject, eventdata, handles)% hObject    handle to signalamp (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on button press in Grid.function Grid_Callback(hObject, eventdata, handles)if (get(handles.Grid,'Value'))==(get(handles.Grid,'Max'))    set(handles.GridOn,'Checked','On');    set(handles.GridOff,'Checked','Off');else    set(handles.GridOn,'Checked','Off');    set(handles.GridOff,'Checked','On');end% hObject    handle to Grid (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of Grid% --- Executes on button press in Legend.function Legend_Callback(hObject, eventdata, handles)% hObject    handle to Legend (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hint: get(hObject,'Value') returns toggle state of Legend% --- Executes on button press in guan.function guan_Callback(hObject, eventdata, handles)A=str2num(get(handles.A_input,'string'));B=str2num(get(handles.B_input,'string'));C=str2num(get(handles.C_input,'string'));D=0;To=obsv(A,C);[Ao,Bo,Co,Do]=ss2ss(A,B,C,D,To);set(handles.ao,'string',num2str(Ao));set(handles.bo,'string',num2str(Bo));set(handles.co,'string',num2str(Co));% hObject    handle to guan (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on button press in kong.function kong_Callback(hObject, eventdata, handles)A=str2num(get(handles.A_input,'string'));B=str2num(get(handles.B_input,'string'));C=str2num(get(handles.C_input,'string'));D=0;T=ctrb(A,B);[Ac,Bc,Cc,Dc]=ss2ss(A,B,C,D,inv(T));set(handles.ac,'string',num2str(Ac));set(handles.bc,'string',num2str(Bc));set(handles.cc,'string',num2str(Cc));% hObject    handle to kong (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)function A_input_Callback(hObject, eventdata, handles)% hObject    handle to A_input (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of A_input as text%        str2double(get(hObject,'String')) returns contents of A_input as a double% --- Executes during object creation, after setting all properties.function A_input_CreateFcn(hObject, eventdata, handles)% hObject    handle to A_input (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endfunction B_input_Callback(hObject, eventdata, handles)% hObject    handle to B_input (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of B_input as text%        str2double(get(hObject,'String')) returns contents of B_input as a double% --- Executes during object creation, after setting all properties.function B_input_CreateFcn(hObject, eventdata, handles)% hObject    handle to B_input (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');endfunction C_input_Callback(hObject, eventdata, handles)% hObject    handle to C_input (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of C_input as text%        str2double(get(hObject,'String')) returns contents of C_input as a double% --- Executes during object creation, after setting all properties.function C_input_CreateFcn(hObject, eventdata, handles)% hObject    handle to C_input (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end% --- Executes on button press in step_pb.function step_pb_Callback(hObject, eventdata, handles)num=str2num(get(handles.num,'String'));den=str2num(get(handles.den,'String'));sys=tf(num,den);y=step(handles.bodeplot,sys);plot(handles.bodeplot,y*(get(handles.signalamp,'Value')));if (get(handles.Grid,'Value'))==(get(handles.Grid,'Max'))    grid on;else    grid off;endif (get(handles.Legend,'Value'))==(get(handles.Legend,'Max'))    legend('on');else    legend('off');end% hObject    handle to step_pb (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on button press in impulse_pb.function impulse_pb_Callback(hObject, eventdata, handles)num=str2num(get(handles.num,'String'));den=str2num(get(handles.den,'String'));sys=tf(num,den);y=impulse(handles.bodeplot,sys);plot(handles.bodeplot,y*(get(handles.signalamp,'Value')));if (get(handles.Grid,'Value'))==(get(handles.Grid,'Max'))    grid on;else    grid off;endif (get(handles.Legend,'Value'))==(get(handles.Legend,'Max'))    legend('on');else    legend('off');end% hObject    handle to impulse_pb (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function Untitled_1_Callback(hObject, eventdata, handles)% hObject    handle to Untitled_1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function Untitled_2_Callback(hObject, eventdata, handles)% hObject    handle to Untitled_2 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function Untitled_3_Callback(hObject, eventdata, handles)% hObject    handle to Untitled_3 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function Untitled_4_Callback(hObject, eventdata, handles)% hObject    handle to Untitled_4 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function GridOn_Callback(hObject, eventdata, handles)gridon=get(handles.Grid,'Max');set(handles.Grid,'Value',gridon);set(handles.GridOn,'Checked','On');set(handles.GridOff,'Checked','Off');% hObject    handle to GridOn (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --------------------------------------------------------------------function GridOff_Callback(hObject, eventdata, handles)gr=get(handles.Grid,'Min');set(handles.Grid,'Value',gr);set(handles.GridOn,'Checked','Off');set(handles.GridOff,'Checked','On');% hObject    handle to GridOff (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on button press in pushbutton9.function pushbutton9_Callback(hObject, eventdata, handles)% hObject    handle to pushbutton9 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -