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

📄 fourpole1.m

📁 控制系统仿真中的根轨迹MATLAB仿真源码
💻 M
📖 第 1 页 / 共 2 页
字号:
function slider_b_Callback(hObject, eventdata, handles)% hObject    handle to slider_b (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 sliderset(handles.edit_b,'string',num2str(get(handles.slider_b,'value')));
val2=str2num(get(handles.edit_b,'string'))
b=str2num(get(handles.edit_b,'string'))
if isnumeric(val2)&length(val2)==1&...
        val2>=get(handles.slider_b,'Min')&...
        val2<=get(handles.slider_b,'Max')
    set(handles.slider_b,'Value',val2);
else  handles.numberofErrors=handles.numberofErrors+1;
    set(handles.edit_b,'String',...
        [handles.errorString,num2str(handle.numberofErrors)]);
    guidata(gcbo,handle);
end
set(handles.edit_a,'string',num2str(get(handles.slider_a,'value')));
val1=str2num(get(handles.edit_a,'string'))
a=str2num(get(handles.edit_a,'string'))
if isnumeric(val1)&length(val1)==1&...
        val1>=get(handles.slider_a,'Min')&...
        val1<=get(handles.slider_a,'Max')
    set(handles.slider_a,'Value',val1);
else  handles.numberofErrors=handles.numberofErrors+1;
    set(handles.edit_a,'String',...
        [handles.errorString,num2str(handle.numberofErrors)]);
    guidata(gcbo,handle);
end
set(handles.edit_c,'string',num2str(get(handles.slider_c,'value')));
val3=str2num(get(handles.edit_c,'string'))
c=str2num(get(handles.edit_c,'string'))
if isnumeric(val3)&length(val3)==1&...
        val3>=get(handles.slider_c,'Min')&...
        val3<=get(handles.slider_c,'Max')
    set(handles.slider_c,'Value',val3);
else  handles.numberofErrors=handles.numberofErrors+1;
    set(handles.edit_c,'String',...
        [handles.errorString,num2str(handle.numberofErrors)]);
    guidata(gcbo,handle);
end
p1=0
p2=-(a+b)
p3=-a+(1/2)*c*i
p4=-a-(1/2)*c*i
z=[]
p=[p1 p2 p3 p4]
sys=zpk(z,p,1)
subplot('Position',[0.1,0.35,0.422,0.5])
rlocus(sys)
num=poly(z)
den=poly(p)
syms('x','w','k','real')
n=poly2sym(k*num,x)
d=poly2sym(den,x)
f=n+d
g=w*i
h=compose(f,g)
r=real(h)
l=simplify(imag(h))
[k,w]=solve(r,l)
k1=sym2poly(k)
set(handles.edit_stastic,'string',min(k1))
set(handles.edit_stastic1,'string',max(k1))

% --- Executes during object creation, after setting all properties.function slider_c_CreateFcn(hObject, eventdata, handles)% hObject    handle to slider_c (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, change%       'usewhitebg' to 0 to use default.  See ISPC and COMPUTER.usewhitebg = 1;if usewhitebg    set(hObject,'BackgroundColor',[.9 .9 .9]);else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end% --- Executes on slider movement.function slider_c_Callback(hObject, eventdata, handles)% hObject    handle to slider_c (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 sliderset(handles.edit_c,'string',num2str(get(handles.slider_c,'value')));
val3=str2num(get(handles.edit_c,'string'))
c=str2num(get(handles.edit_c,'string'))
if isnumeric(val3)&length(val3)==1&...
        val3>=get(handles.slider_c,'Min')&...
        val3<=get(handles.slider_c,'Max')
    set(handles.slider_c,'Value',val3);
else  handles.numberofErrors=handles.numberofErrors+1;
    set(handles.edit_c,'String',...
        [handles.errorString,num2str(handle.numberofErrors)]);
    guidata(gcbo,handle);
end
set(handles.edit_b,'string',num2str(get(handles.slider_b,'value')));
val2=str2num(get(handles.edit_b,'string'))
b=str2num(get(handles.edit_b,'string'))
if isnumeric(val2)&length(val2)==1&...
        val2>=get(handles.slider_b,'Min')&...
        val2<=get(handles.slider_b,'Max')
    set(handles.slider_b,'Value',val2);
else  handles.numberofErrors=handles.numberofErrors+1;
    set(handles.edit_b,'String',...
        [handles.errorString,num2str(handle.numberofErrors)]);
    guidata(gcbo,handle);
end
set(handles.edit_a,'string',num2str(get(handles.slider_a,'value')));
val1=str2num(get(handles.edit_a,'string'))
a=str2num(get(handles.edit_a,'string'))
if isnumeric(val1)&length(val1)==1&...
        val1>=get(handles.slider_a,'Min')&...
        val1<=get(handles.slider_a,'Max')
    set(handles.slider_a,'Value',val1);
else  handles.numberofErrors=handles.numberofErrors+1;
    set(handles.edit_a,'String',...
        [handles.errorString,num2str(handle.numberofErrors)]);
    guidata(gcbo,handle);
end
p1=0
p2=-(a+b)
p3=-a+(1/2)*c*i
p4=-a-(1/2)*c*i
z=[]
p=[p1 p2 p3 p4]
sys=zpk(z,p,1)
subplot('Position',[0.1,0.35,0.422,0.5])
rlocus(sys)
num=poly(z)
den=poly(p)
syms('x','w','k','real')
n=poly2sym(k*num,x)
d=poly2sym(den,x)
f=n+d
g=w*i
h=compose(f,g)
r=real(h)
l=simplify(imag(h))
[k,w]=solve(r,l)
k1=sym2poly(k)
set(handles.edit_stastic,'string',min(k1))
set(handles.edit_stastic1,'string',max(k1))

% --- Executes during object creation, after setting all properties.function edit_c_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_c (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction edit_c_Callback(hObject, eventdata, handles)% hObject    handle to edit_c (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 edit_c as text%        str2double(get(hObject,'String')) returns contents of edit_c as a double% --- Executes during object creation, after setting all properties.function edit_stastic_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_stastic (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction edit_stastic_Callback(hObject, eventdata, handles)% hObject    handle to edit_stastic (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 edit_stastic as text%        str2double(get(hObject,'String')) returns contents of edit_stastic as a double% --- Executes during object creation, after setting all properties.function edit_stastic1_CreateFcn(hObject, eventdata, handles)% hObject    handle to edit_stastic1 (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    set(hObject,'BackgroundColor','white');else    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endfunction edit_stastic1_Callback(hObject, eventdata, handles)% hObject    handle to edit_stastic1 (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 edit_stastic1 as text%        str2double(get(hObject,'String')) returns contents of edit_stastic1 as a double% --------------------------------------------------------------------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)button=questdlg('Do you want to close this window?',...
    'Close Operation','Yes','No','No');
if strcmp(button,'Yes')
   close
elseif strcmp(button,'No')
    disp('Canceled file operation')
end

⌨️ 快捷键说明

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