function varargout = xinxilun(varargin)
% XINXILUN MATLAB code for xinxilun.fig
% XINXILUN, by itself, creates a new XINXILUN or raises the existing
% singleton*.
%
% H = XINXILUN returns the handle to a new XINXILUN or the handle to
% the existing singleton*.
%
% XINXILUN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in XINXILUN.M with the given input arguments.
%
% XINXILUN('Property','Value',...) creates a new XINXILUN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before xinxilun_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to xinxilun_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help xinxilun
% Last Modified by GUIDE v2.5 04-Dec-2013 16:15:30
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @xinxilun_OpeningFcn, ...
'gui_OutputFcn', @xinxilun_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before xinxilun is made visible.
function xinxilun_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to xinxilun (see VARARGIN)
% Choose default command line output for xinxilun
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
axes(handles.axes1);
axis off;
axes(handles.axes2);
axis off;
% UIWAIT makes xinxilun wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = xinxilun_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function m_in_Callback(hObject, eventdata, handles)
% hObject handle to m_in (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 m_in as text
% str2double(get(hObject,'String')) returns contents of m_in as a double
% --- Executes during object creation, after setting all properties.
function m_in_CreateFcn(hObject, eventdata, handles)
% hObject handle to m_in (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 bm_pushbutton.
function bm_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to bm_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global c;
mm=get(handles.m_in,'string');
if length(mm)~=4
errordlg('信息码字长度只能是4位!','非法输入!');
elseif length(mm)==4
for i=1:4
m(i)=str2num(mm(i)); %判断输入是否合法
end
if ((m(1)~=0&&m(1)~=1)||(m(2)~=0&&m(2)~=1)||(m(3)~=0&&m(3)~=1)||(m(4)~=0&&m(4)~=1))
errordlg('只能输入0或1!','非法输入!');
else
set(handles.jspanel,'visible','on');
c=coding(m); %调用函数编码
cc=num2str(c(1,1:7));
set(handles.text3,'visible','on');
set(handles.m_out_text,'string',cc); %画图
axes(handles.axes1);
stairs(0:7,c,'linewidth',2);
axis([0,7,0,1]);
set(gca,'XTick',0:1:7);
set(gca,'YTick',[]);
grid on;
end
end
function e_edit_Callback(hObject, eventdata, handles)
% hObject handle to e_edit (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 e_edit as text
% str2double(get(hObject,'String')) returns contents of e_edit as a double
% --- Executes during object creation, after setting all properties.
function e_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to e_edit (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 e_button.
function e_button_Callback(hObject, eventdata, handles)
% hObject handle to e_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
out =randi([0 7],1);
e=zeros(1,7);
if out~=0
e(out)=1;
end
for i=1:7
ee(i)=num2str(e(i)); %转化为字符串
end
set(handles.e_edit,'string',ee);
% --- Executes on button press in dj_button.
function dj_button_Callback(hObject, eventdata, handles)
% hObject handle to dj_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global r;
global c;
ee=get(handles.e_edit,'string');
if length(ee)~=7
errordlg('错误图样长度是7位!','非法输入!');
elseif length(ee)==7
for i=1:7
e(i)=str2num(ee(i));
end
if ((e(1)~=0&&e(1)~=1)||(e(2)~=0&&e(2)~=1)||(e(3)~=0&&e(3)~=1)||(e(4)~=0&&e(4)~=1)||(e(5)~=0&&e(5)~=1)||(e(6)~=0&&e(6)~=1)||(e(7)~=0&&e(7)~=1))
errordlg('只能输入0或1!','非法输入!');
elseif sum(e)>1
errordlg('超出纠错范围,只能纠1位错,请重新输入!','非法输入!');
else
set(handles.uipanel3,'visible','on');
r=xor(c(1,1:7),e);
rr=num2str(r);
set(handles.text7,'visible','on');
set(handles.r_text,'string',rr); %画图
axes(handles.axes2);
stairs(0:7,[r,r(7)],'linewidth',2);
axis([0,7,0,1]);
set(gca,'XTick',0:1:7);
set(gca,'YTick',[]);
grid on;
end
end
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO
天天Matlab科研工作室
- 粉丝: 4w+
- 资源: 1万+
最新资源
- Vba常用api函数使用.zip
- 西门子变频器 SINAMICS STARTER V5.6 HF2 软件 STARTER V56 STARTERV56HF2-cd-1.zip.009
- 多客圈子系统免费源码 社交圈子搭建 前端Uniapp 后端php 可二开 多端运行
- 统信国产操作系统升级ssh(桌面版)
- STM32快速入门01代码
- TDA系列双轴气缸.pdf
- 安徽皖南电机样本.pdf
- 伺服提升机选型.pdf
- 单向推力球轴承.pdf
- 德国peiseler派士乐数控转台样本.pdf
- 低速大扭矩液压马达.pdf
- 电液伺服阀维修样本.pdf
- 贺德克电子产品样本.pdf
- 机械阀VM系列.pdf
- 凯芯PSRAM芯片选型表
- 凯特精机样本.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈