Info

此问题已关闭。 请重新打开它进行编辑或回答。

I am trying to plot a figure in GUI through a button event. Please rectify the errors in the Code as it is not plotting the data simultaneously in GUI.

1 次查看(过去 30 天)
function varargout = fixed1(varargin)
% FIXED1 MATLAB code for fixed1.fig
% FIXED1, by itself, creates a new FIXED1 or raises the existing
% singleton*.
%
% H = FIXED1 returns the handle to a new FIXED1 or the handle to
% the existing singleton*.
%
% FIXED1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in FIXED1.M with the given input arguments.
%
% FIXED1('Property','Value',...) creates a new FIXED1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before fixed1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to fixed1_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 fixed1
% Last Modified by GUIDE v2.5 27-Mar-2018 19:45:37
% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @fixed1_OpeningFcn, ... 'gui_OutputFcn', @fixed1_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 fixed1 is made visible. function fixed1_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 fixed1 (see VARARGIN)
% Choose default command line output for fixed1 handles.output = hObject;
% Update handles structure guidata(hObject, handles);
% UIWAIT makes fixed1 wait for user response (see UIRESUME) % uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line. function varargout = fixed1_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;
% --- Executes on button press in trellis. function trellis_Callback(hObject, eventdata, handles) % hObject handle to trellis (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) axes(handles.axes1) xlim(handles.axes1,[0 10]) ylim(handles.axes1,[-2 8]) % FigHandle= axes set(axes,'position',[100 50 1049 695]); op =[ 1 1 0 1 1 0 1 0 0 1 0 0 1 0 1 1 0 0]
% hold on text(0.5,4,'00') text(0.5,3,'01') text(0.5,2,'10') text(0.5,1,'11') % text(6,7,'2----','color','r') % text(6,6.5,'0----','color','g') % text(6,6,'1----','color','b') text(0.5,4.5,'Received:') text(0.5,0.5,'msg decoded:') % text(0.5,00,'msg Rx:')
%trellis graph l=1; i=1; d1=0,d2=0; k=0; p=[0 0]; a=[op(i) op(i+1)] text(1.5,4.5,num2str(a)) a1=pdist2(p,a,'hamming') line([1 2],[4 4],'Color','black','linestyle','--','linewidth',2) k=1; p=[1 1]; a=[op(i) op(i+1)]; b1=pdist2(p,a,'hamming') line([1 2],[4 2],'color','red','linewidth',2) m=min(a1,b1) if(m==a1) z(l)=[0] end if(m==b1) z(l)=[1] end
%Stage 3 l=l+1; i=i+2; d1=0,d2=0; k=0; p=[0 0]; a=[op(i) op(i+1)]; text(2.5,4.5,num2str(a)) a2=pdist2(p,a,'hamming') line([2 3],[4 4],'color','black','linestyle','--','linewidth',2) k=1; p=[1 1]; a=[op(i) op(i+1)]; b2=pdist2(p,a,'hamming') line([2 3],[4 2],'color','red','linewidth',2) d1=1,d2=0 k=0; p=[1 0]; a=[op(i) op(i+1)]; c2=pdist2(p,a,'hamming') line([2 3],[2 3],'color','black','linestyle','--','linewidth',2) k=1; p=[0 1]; a=[op(i) op(i+1)]; dp=pdist2(p,a,'hamming') line([2 3],[2 1],'color','red','linewidth',2) s31=a1+a2; s32=b1+c2; s33=a1+b2; s34=b1+dp; A=[s31,s32,s33,s34] m=min(A) if(m==s31) z(l)=[0]; end if(m==s32) z(l)=[0]; end if(m==s33) z(l)=[1]; end if(m==s34) z(l)=[1]; end
%stage 4 % n2=n-2; n2=7; x=1:n2+1; A1=s31; B1=s32;C1=s33;D1=s34; for l=3:n2 i=i+2; d1=0,d2=0; k=0; p=[0 0] a=[op(i) op(i+1)]; text(l+0.5,4.5,num2str(a)) a3=pdist2(p,a,'hamming') line([x(l) x(l+1)],[4 4],'linewidth',2,'color','black','linestyle','--') k=1 p=[1 1] a=[op(i) op(i+1)] b3=pdist2(p,a,'hamming') line([x(l) x(l+1)],[4 2],'linewidth',2,'color','red') d1=0, d2=1 k=0 p=[1 1] a=[op(i) op(i+1)] e3=pdist2(p,a,'hamming') line([x(l) x(l+1)],[3 4],'linewidth',2,'color','black','linestyle','--') k=1 p=[0 0] a=[op(i) op(i+1)] f3=pdist2(p,a,'hamming') line([x(l) x(l+1)],[3 2],'linewidth',2,'color','red') d1=1,d2=0 k=0 p=[1 0] a=[op(i) op(i+1)] c3=pdist2(p,a,'hamming') line([x(l) x(l+1)],[2 3],'linewidth',2,'color','black','linestyle','--') k=1 p=[0 1] a=[op(i) op(i+1)] d3=pdist2(p,a,'hamming') line([x(l) x(l+1)],[2 1],'linewidth',2,'color','red') d1=1,d2=1 k=0 p=[0 1] a=[op(i) op(i+1)] g3=pdist2(p,a,'hamming') line([x(l) x(l+1)],[1 3],'linewidth',2,'color','black','linestyle','--') k=1 p=[1 0] a=[op(i) op(i+1)] h3=pdist2(p,a,'hamming') line([x(l) x(l+1)],[1 1],'linewidth',2,'color','red') s41=a3+A1 s45=b3+A1 s42=e3+B1 s46=f3+B1 s43=c3+C1 s47=d3+C1 s44=g3+D1 s48=h3+D1 A1=min(s41,s42) B1=min(s43,s44) C1=min(s45,s46) D1=min(s47,s48) e=[A1 B1 C1 D1] E(l,:)=[e] end
% q=n % for l=n2:-1:1 % A=[E(l,:)] % m=min(A) % if(m==(E(l,1))|| m==(E(l,2))) % z(q)=0 % end % if(m==(E(l,3))||m==(E(l,4))) % z(q)=1 % end % q=q-1; % end % opp=[z]
l=1; i=1; d1=0,d2=0; k=0; p=[0 0]; a=[op(i) op(i+1)]; text(1.5,4.5,num2str(a)) a1=pdist2(p,a,'hamming') line([1 2],[4 2],'color','blue','linewidth',2)
l=l+1; i=i+2; d1=0,d2=0; k=0; p=[0 0]; a=[op(i) op(i+1)]; text(2.5,4.5,num2str(a)) a2=pdist2(p,a,'hamming') % line([2 3],[2 1],'color','blue','linewidth',2) k=1; p=[1 1]; a=[op(i) op(i+1)]; b2=pdist2(p,a,'hamming') line([2 3],[2 1],'color','blue','linewidth',2)
%stage 3 l=l+1; i=i+2; d1=0,d2=0; k=0; p=[0 0]; a=[op(i) op(i+1)]; text(2.5,4.5,num2str(a)) a2=pdist2(p,a,'hamming') line([3 4],[1 1],'color','blue','linewidth',2)
l=l+1; i=i+2; d1=0,d2=0; k=1; p=[1 1]; a=[op(i) op(i+1)]; text(2.5,4.5,num2str(a)) a2=pdist2(p,a,'hamming') line([4 5],[1 1],'color','blue','linewidth',2)
i=i+2; d1=0,d2=0; k=0; p=[0 0]; a=[op(i) op(i+1)]; text(3.5,4.5,num2str(a)) a3=pdist2(p,a,'hamming') line([5 6],[1 3],'color','green','linestyle','--','linewidth',2)
l=l+1; i=i+2; d1=0,d2=0; k=1; p=[1 1]; a=[op(i) op(i+1)]; text(2.5,4.5,num2str(a)) a2=pdist2(p,a,'hamming') line([6 7],[3 2],'color','blue','linewidth',2)
i=i+2; d1=0,d2=0; k=0; p=[0 0]; a=[op(i) op(i+1)]; text(3.5,4.5,num2str(a)) a3=pdist2(p,a,'hamming') line([7 8],[2 3],'color','green','linestyle','--','linewidth',2) plot(handles.axes1)
  2 个评论
Walter Roberson
Walter Roberson 2018-3-30
You need to post the complete error message, everything in red, or else you need to describe the error you are getting.
We cannot possibly run your code, as you have not supplied the .fig file or the rest of the functions that would be needed by your GUI.

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by