Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

plotting a signal

1 visualización (últimos 30 días)
contessa mima
contessa mima el 25 de Feb. de 2012
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
i can't run this code:
function varargout = plotSg(varargin)
% PLOTSG M-file for plotSg.fig
% PLOTSG, by itself, creates a new PLOTSG or raises the existing
% singleton*.
%
% H = PLOTSG returns the handle to a new PLOTSG or the handle to
% the existing singleton*.
%
% PLOTSG('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in PLOTSG.M with the given input arguments.
%
% PLOTSG('Property','Value',...) creates a new PLOTSG or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before plotSg_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to plotSg_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 plotSg
% Last Modified by GUIDE v2.5 25-Feb-2012 10:07:34
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @plotSg_OpeningFcn, ...
'gui_OutputFcn', @plotSg_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 plotSg is made visible.
function plotSg_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 plotSg (see VARARGIN)
% Choose default command line output for plotSg
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes plotSg wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = plotSg_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 plotButton.
function plotButton_Callback(hObject, eventdata, handles)
% hObject handle to plotButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%get the freq and cnvert it to number
freq=str2num(get(handles.edit1('string')))
%creer sg
x=0:2*pi/1000:2*pi;
x=sin(freq*x);
%impoter sg ds axe
axes=(handles.axes1);
%plot sg
plot(x);
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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 checkbox3.
function checkbox3_Callback(hObject, eventdata, handles)
% hObject handle to checkbox3 (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 checkbox3
% --- Executes on button press in checkbox4.
function checkbox4_Callback(hObject, eventdata, handles)
% hObject handle to checkbox4 (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 checkbox4
  2 comentarios
Walter Roberson
Walter Roberson el 25 de Feb. de 2012
What prevents you from running it?
Walter Roberson
Walter Roberson el 28 de Feb. de 2012
I do not have the .fig file so I cannot test this code.
Line 84 is dubious. It currently says
axes=(handles.axes1);
which assigns a value to a _variable_ named "axes", rather than calling the axes() routine. The code would make more sense without the "=" there.

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by