sine wave

3 visualizaciones (últimos 30 días)
simira atraqi
simira atraqi el 5 de Abr. de 2012
Can any one help me to run this program?
function varargout = simira(varargin)
% - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @simira_OpeningFcn, ...
'gui_OutputFcn', @simira_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
function varargout = simira_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% - DO NOT EDIT
% --- Project Opening Function.============================================
function simira_OpeningFcn(hObject, eventdata, handles, varargin)
% Default values
handles.xl=4000;
handles.yl=3000;
handles.Am=3;
handles.Fr=2000;
handles.output = hObject;
guidata(hObject, handles);
% --- X length slider.=====================================================
function slider1_Callback(hObject, eventdata, handles)
handles.xl=get(hObject,'value');
set(handles.text1,'string',strcat('Xlength=',num2str(handles.xl,'%4.f'),'µm'));
guidata(hObject, handles);
[t y A]=simiraFun(handles.xl,handles.yl,handles.Am,handles.Fr);
surf(t,y,A);
shading interp
function slider1_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
%==========================================================================
% --- Y length slider.=====================================================
function slider2_Callback(hObject, eventdata, handles)
handles.yl=get(hObject,'value');
set(handles.text2,'string',strcat('Ylength=',num2str(handles.yl,'%4.f'),'µm'));
guidata(hObject, handles);
[t y A]=simiraFun(handles.xl,handles.yl,handles.Am,handles.Fr);
surf(t,y,A);
shading interp
function slider2_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
%==========================================================================
% --- Amplitude slider.====================================================
function slider3_Callback(hObject, eventdata, handles)
handles.Am=get(hObject,'value');
set(handles.text3,'string',strcat('Amplitude=',num2str(handles.Am,'%1.f'),'µm'));
guidata(hObject, handles);
[t y A]=simiraFun(handles.xl,handles.yl,handles.Am,handles.Fr);
surf(t,y,A);
shading interp
function slider3_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
%==========================================================================
% --- Frequency slider.====================================================
function slider4_Callback(hObject, eventdata, handles)
handles.Fr=get(hObject,'value');
set(handles.text4,'string',strcat('Frequency=',num2str(handles.Fr,'%1.f'),'Hz'));
guidata(hObject, handles);
[t y A]=simiraFun(handles.xl,handles.yl,handles.Am,handles.Fr);
surf(t,y,A);
shading interp
function slider4_CreateFcn(hObject, eventdata, handles)
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
%==========================================================================
% --- Plot pushbutton.=====================================================
function pushbutton1_Callback(hObject, eventdata, handles)
[t y A]=simiraFun(handles.xl,handles.yl,handles.Am,handles.Fr);
surf(t,y,A);
shading interp
%==========================================================================
% --- Clear pushbutton.====================================================
function pushbutton2_Callback(hObject, eventdata, handles)
cla
%==========================================================================
And this the function
function [t y A]=simiraFun(xl,yl,am,fr)
Fre=fr/1000000;
SFre=4*Fre;
t=0:(1/SFre):xl;
x=am*sin(Fre*t);
A=ones(yl+1 ,1)*x;
y=0:yl;
Any help would be greatly appreciated. Simira
  1 comentario
Wayne King
Wayne King el 5 de Abr. de 2012
You should format this code for people to read.

Iniciar sesión para comentar.

Respuestas (2)

Image Analyst
Image Analyst el 5 de Abr. de 2012
Probably not. Because it's a GUIDE program and you supplied only the m-file and not the .fig file so we can't run it. Plus you didn't say why we should, like what kind of strange behavior or error that we should look for and try to fix. So it's unlikely that anyone would want to build a GUI and run your program, when you've given no guidance as to what kind of help you need.

simira atraqi
simira atraqi el 5 de Abr. de 2012
I need to run this program, but I do not know how I can attach it with the file of function and figure.
  1 comentario
Image Analyst
Image Analyst el 5 de Abr. de 2012
This should have been a "comment" to my "Answer" rather than an "Answer" by you.
What ever happened to your .fig file? Did you create this, or did someone else give you only the .fig file and forget to give you their .fig file?

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by