contara
Computer
- Jul 10, 2007
- 1
Hi everybody,
I am a new one here and i need your help. I need to know what is wrong with the program i am writing on Matlab 6.
Its GUI form for solving differential equations and visualization of the results. I am using radiobuttons for switching the solvers but something is wrong with ode functions and i cant help it by myself.
Thank you,
Here is the code:
function varargout = Visualization(varargin)
% VISUALIZATION M-file for Visualization.fig
% VISUALIZATION, by itself, creates a new VISUALIZATION or raises the existing
% singleton*.
%
% H = VISUALIZATION returns the handle to a new VISUALIZATION or the handle to
% the existing singleton*.
%
% VISUALIZATION('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in VISUALIZATION.M with the given input arguments.
%
% VISUALIZATION('Property','Value',...) creates a new VISUALIZATION or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Visualization_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Visualization_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 Visualization
% Last Modified by GUIDE v2.5 10-Jul-2007 13:35:51
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Visualization_OpeningFcn, ...
'gui_OutputFcn', @Visualization_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 Visualization is made visible.
function Visualization_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 Visualization (see VARARGIN)
% Choose default command line output for Visualization
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Visualization wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Visualization_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 during object creation, after setting all properties.
function m_CreateFcn(hObject, eventdata, handles)
% hObject handle to m (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'));
end
function m_Callback(hObject, eventdata, handles)
% hObject handle to m (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 as text
% str2double(get(hObject,'String')) returns contents of m as a double
% --- Executes during object creation, after setting all properties.
function q_CreateFcn(hObject, eventdata, handles)
% hObject handle to q (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'));
end
function q_Callback(hObject, eventdata, handles)
% hObject handle to q (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 q as text
% str2double(get(hObject,'String')) returns contents of q as a double
% --- Executes during object creation, after setting all properties.
function u1_CreateFcn(hObject, eventdata, handles)
% hObject handle to u1 (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'));
end
function u1_Callback(hObject, eventdata, handles)
% hObject handle to u1 (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 u1 as text
% str2double(get(hObject,'String')) returns contents of u1 as a double
% --- Executes during object creation, after setting all properties.
function u2_CreateFcn(hObject, eventdata, handles)
% hObject handle to u2 (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'));
end
function u2_Callback(hObject, eventdata, handles)
% hObject handle to u2 (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 u2 as text
% str2double(get(hObject,'String')) returns contents of u2 as a double
% --- Executes during object creation, after setting all properties.
function L1_CreateFcn(hObject, eventdata, handles)
% hObject handle to L1 (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'));
end
function L1_Callback(hObject, eventdata, handles)
% hObject handle to L1 (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 L1 as text
% str2double(get(hObject,'String')) returns contents of L1 as a double
% --- Executes during object creation, after setting all properties.
function L2_CreateFcn(hObject, eventdata, handles)
% hObject handle to L2 (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'));
end
function L2_Callback(hObject, eventdata, handles)
% hObject handle to L2 (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 L2 as text
% str2double(get(hObject,'String')) returns contents of L2 as a double
% --- Executes during object creation, after setting all properties.
function alfa_CreateFcn(hObject, eventdata, handles)
% hObject handle to alfa (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'));
end
function alfa_Callback(hObject, eventdata, handles)
% hObject handle to alfa (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 alfa as text
% str2double(get(hObject,'String')) returns contents of alfa as a double
% --- Executes during object creation, after setting all properties.
function f1_CreateFcn(hObject, eventdata, handles)
% hObject handle to f1 (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'));
end
function f1_Callback(hObject, eventdata, handles)
% hObject handle to f1 (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 f1 as text
% str2double(get(hObject,'String')) returns contents of f1 as a double
% --- Executes during object creation, after setting all properties.
function f2_CreateFcn(hObject, eventdata, handles)
% hObject handle to f2 (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'));
end
function f2_Callback(hObject, eventdata, handles)
% hObject handle to f2 (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 f2 as text
% str2double(get(hObject,'String')) returns contents of f2 as a double
% --- Executes during object creation, after setting all properties.
function x_CreateFcn(hObject, eventdata, handles)
% hObject handle to x (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'));
end
function x_Callback(hObject, eventdata, handles)
% hObject handle to x (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 x as text
% str2double(get(hObject,'String')) returns contents of x as a double
% --- Executes during object creation, after setting all properties.
function xpr_CreateFcn(hObject, eventdata, handles)
% hObject handle to xpr (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'));
end
function xpr_Callback(hObject, eventdata, handles)
% hObject handle to xpr (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 xpr as text
% str2double(get(hObject,'String')) returns contents of xpr as a double
% --- Executes during object creation, after setting all properties.
function y_CreateFcn(hObject, eventdata, handles)
% hObject handle to y (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'));
end
function y_Callback(hObject, eventdata, handles)
% hObject handle to y (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 y as text
% str2double(get(hObject,'String')) returns contents of y as a double
% --- Executes during object creation, after setting all properties.
function ypr_CreateFcn(hObject, eventdata, handles)
% hObject handle to ypr (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'));
end
function ypr_Callback(hObject, eventdata, handles)
% hObject handle to ypr (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 ypr as text
% str2double(get(hObject,'String')) returns contents of ypr as a double
% --- Executes during object creation, after setting all properties.
function t0_CreateFcn(hObject, eventdata, handles)
% hObject handle to t0 (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'));
end
function t0_Callback(hObject, eventdata, handles)
% hObject handle to t0 (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 t0 as text
% str2double(get(hObject,'String')) returns contents of t0 as a double
% --- Executes during object creation, after setting all properties.
function tend_CreateFcn(hObject, eventdata, handles)
% hObject handle to tend (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'));
end
function tend_Callback(hObject, eventdata, handles)
% hObject handle to tend (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 tend as text
% str2double(get(hObject,'String')) returns contents of tend as a double
%--- Executes on button press in s1.
function s1_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s2;
set(off,'Value',0);
off = handles.s3;
set(off,'Value',0);
off = handles.s4;
set(off,'Value',0);
off = handles.s5;
set(off,'Value',0);
off = handles.s6;
set(off,'Value',0);
off = handles.s7;
set(off,'Value',0);
% --------------------------------------------------------------------
function s2_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s1;
set(off,'Value',0);
off = handles.s3;
set(off,'Value',0);
off = handles.s4;
set(off,'Value',0);
off = handles.s5;
set(off,'Value',0);
off = handles.s6;
set(off,'Value',0);
off = handles.s7;
set(off,'Value',0);
% --------------------------------------------------------------------
function s3_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s1;
set(off,'Value',0);
off = handles.s2;
set(off,'Value',0);
off = handles.s4;
set(off,'Value',0);
off = handles.s5;
set(off,'Value',0);
off = handles.s6;
set(off,'Value',0);
off = handles.s7;
set(off,'Value',0);
% --------------------------------------------------------------------
function s4_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s1;
set(off,'Value',0);
off = handles.s2;
set(off,'Value',0);
off = handles.s3;
set(off,'Value',0);
off = handles.s5;
set(off,'Value',0);
off = handles.s6;
set(off,'Value',0);
off = handles.s7;
set(off,'Value',0);
% --------------------------------------------------------------------
function s5_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s1;
set(off,'Value',0);
off = handles.s2;
set(off,'Value',0);
off = handles.s3;
set(off,'Value',0);
off = handles.s4;
set(off,'Value',0);
off = handles.s6;
set(off,'Value',0);
off = handles.s7;
set(off,'Value',0);
function s6_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s1;
set(off,'Value',0);
off = handles.s2;
set(off,'Value',0);
off = handles.s3;
set(off,'Value',0);
off = handles.s4;
set(off,'Value',0);
off = handles.s5;
set(off,'Value',0);
off = handles.s7;
set(off,'Value',0);
function s7_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s1;
set(off,'Value',0);
off = handles.s2;
set(off,'Value',0);
off = handles.s3;
set(off,'Value',0);
off = handles.s4;
set(off,'Value',0);
off = handles.s5;
set(off,'Value',0);
off = handles.s6;
set(off,'Value',0);
% --- Executes on button press in graphicsplot.
function graphicsplot_Callback(hObject, eventdata, handles)
% hObject handle to graphicsplot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
f1 = str2double(get(handles.f1,'String')); % f1
alfa = str2double(get(handles.alfa,'String')); % alfa
L2 = str2double(get(handles.L2,'String')); % L2
L1 = str2double(get(handles.L1,'String')); % L1
u2 = str2double(get(handles.u2,'String')); % u2
u1 = str2double(get(handles.u1,'String')); % u1
q = str2double(get(handles.q,'String'));
m = str2double(get(handles.m,'String')); % m
f2 = str2double(get(handles.f2,'String')); % f2
% read time intervall
t0 = str2double(get(handles.t0,'String')); % t_0
tend = str2double(get(handles.tend,'String')); % t_N
% read initial datas
y0(1) = str2double(get(handles.x,'String'));
y0(2) = str2double(get(handles.xpr,'String'));
y0(3) = str2double(get(handles.y,'String'));
y0(4) = str2double(get(handles.ypr,'String'));
y0 = [y0(1); y0(2); y0(3); y0(4)];
if (get(handles.s1, 'Value') == 1)
fun=@equation;
[tt,yy] = feval(ode45,fun,[t0 tend],y0,[],m,q,u1,u2,L1,L2,alfa,f1,f2)
end;
if (get(handles.s2, 'Value') == 1)
[tt,yy] = feval(ode23,@equation,[t0 tend],y0,[],m, q, u1, u2, L1, L2, alfa, f1, f2)
end;
if (get(handles.s3, 'Value') == 1)
[tt,yy] = feval(ode113,@equation,[t0 tend], y0,[], m, q, u1, u2, L1, L2, alfa, f1, f2);
end;
if (get(handles.s4, 'Value') == 1)
[tt,yy] = feval(ode15s,@equation,[t0 tend], y0,[], m, q, u1, u2, L1, L2, alfa, f1, f2);
end;
if (get(handles.s5, 'Value') == 1)
[tt,yy] = feval(ode23s,@equation,[t0 tend], y0,[], m, q, u1, u2, L1, L2, alfa, f1, f2);
end;
if (get(handles.s6, 'Value') == 1)
[tt,yy] = feval(ode23t,@equation,[t0 tend], y0,[], m, q, u1, u2, L1, L2, alfa, f1, f2);
end;
if (get(handles.s7, 'Value') == 1)
[tt,yy] = feval(ode23tb,@equation,[t0 tend],y0,[], m, q, u1, u2, L1, L2, alfa, f1, f2);
end;
n=length(tt);
% Visualization
figure(1)
maximize(gcf);
subplot(2,1,1),plot(tt(1:n),yy(1:n,1),'r'),grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('????? t'), ylabel('x')
title('????? ?? ???????? x = x(t)')
subplot(2,1,2),plot(tt(1:n),yy(1:n,3),'b'),grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('????? t'), ylabel('y')
title('????? ?? ???????? y = y(t)')
disp('????????? ?????????? ?????? ?? ???????????!'),pause
figure(2)
maximize(gcf);
subplot(2,1,1),plot(tt(1:n),yy(1:n,2),'r'),grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('????? t'), ylabel('x''')
title('??????? ?? ???????????? x''')
subplot(2,1,2),plot(tt(1:n),yy(1:n,4),'b'),grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('????? t'), ylabel('y''')
title('??????? ?? ???????????? y''')
disp('????????? ?????????? ?????? ?? ???????????!'),pause
figure(3)
maximize(gcf);
comet(yy(1:n,1),yy(1:n,2))
plot(yy(1:n,1),yy(1:n,2),'b'),grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('x'), ylabel('v')
title('?????? ?????????? v = v(x)')
disp('????????? ?????????? ?????? ?? ???????????!'),pause
figure(4)
maximize(gcf);
comet(yy(1:n,3),yy(1:n,4))
plot(yy(1:n,3),yy(1:n,4),'b'), grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('y'), ylabel('v')
title('?????? ?????????? v = v')
disp('????????? ?????????? ?????? ?? ???????????!'),pause
figure(5)
maximize(gcf);
colordef none
% ????????? ?? ??????? ?? ???? ?? ????????? ????????
hs = axes('units','normalized', ...
'position',[0 0 1 1]);
% ??????????? ?? ????????? ? ??????
uistack(hs,'bottom');
% ????????? ?? ????????????? ?? ???
I=imread('krak2.jpg');
hi = imagesc(I);
colormap gray
% ???????? ?? ????? ?? ????? ????????
set(hs ,'visible','off')
set(hi,'alphadata',.5)
axes('position',[0.40,0.25,0.4,0.4])
comet(yy(1:n,1),yy(1:n,3))
plot(yy(1:n,1),yy(1:n,3),'b'), grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('x'), ylabel('y')
title('?????????? ?? ???????? ?? ?????? ')
disp('????????? ?????????? ?????? ?? ???????????!'),pause
figure(6)
maximize(gcf);
colordef none
hs = axes('units','normalized', ...
'position',[0 0 1 1]);
uistack(hs,'bottom');
I=imread('krak2.jpg');
hi = imagesc(I);
colormap gray
set(hs ,'visible','off')
set(hi,'alphadata',.5)
axes('position',[0.40,0.25,0.4,0.4])
comet3(yy(1:n,1),yy(1:n,3),tt(1:n)),grid on
plot3(yy(1:n,1),yy(1:n,3),tt(1:n),'b'),grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('x'), ylabel('y'), zlabel('t')
title('?????????? ?? ???????? ?? ??????')
disp('????????? ?????????? ?????? ?? ???????????!'),pause
function f = equation(t,y, m, q, u1, u2, L1, L2, alfa, f1, f2)
% global m, q, u1, u2, L1, L2, alfa, f1, f2
% ?????????? ?? ????????????
% f=zeros(4,1);
f(1)=y(2);
f(2)=q/m*(u1/L1)*cos(2*pi*f1*t)+q/m*(u2/L2)*cos(alfa)*cos(2*pi*f2*t);
f(3)=y(4);
f(4)=q/m*(u2/L2)*sin(alfa)*cos(2*pi*f2*t);
I am a new one here and i need your help. I need to know what is wrong with the program i am writing on Matlab 6.
Its GUI form for solving differential equations and visualization of the results. I am using radiobuttons for switching the solvers but something is wrong with ode functions and i cant help it by myself.
Thank you,
Here is the code:
function varargout = Visualization(varargin)
% VISUALIZATION M-file for Visualization.fig
% VISUALIZATION, by itself, creates a new VISUALIZATION or raises the existing
% singleton*.
%
% H = VISUALIZATION returns the handle to a new VISUALIZATION or the handle to
% the existing singleton*.
%
% VISUALIZATION('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in VISUALIZATION.M with the given input arguments.
%
% VISUALIZATION('Property','Value',...) creates a new VISUALIZATION or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Visualization_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Visualization_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 Visualization
% Last Modified by GUIDE v2.5 10-Jul-2007 13:35:51
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Visualization_OpeningFcn, ...
'gui_OutputFcn', @Visualization_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(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 Visualization is made visible.
function Visualization_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 Visualization (see VARARGIN)
% Choose default command line output for Visualization
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Visualization wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Visualization_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 during object creation, after setting all properties.
function m_CreateFcn(hObject, eventdata, handles)
% hObject handle to m (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'));
end
function m_Callback(hObject, eventdata, handles)
% hObject handle to m (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 as text
% str2double(get(hObject,'String')) returns contents of m as a double
% --- Executes during object creation, after setting all properties.
function q_CreateFcn(hObject, eventdata, handles)
% hObject handle to q (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'));
end
function q_Callback(hObject, eventdata, handles)
% hObject handle to q (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 q as text
% str2double(get(hObject,'String')) returns contents of q as a double
% --- Executes during object creation, after setting all properties.
function u1_CreateFcn(hObject, eventdata, handles)
% hObject handle to u1 (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'));
end
function u1_Callback(hObject, eventdata, handles)
% hObject handle to u1 (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 u1 as text
% str2double(get(hObject,'String')) returns contents of u1 as a double
% --- Executes during object creation, after setting all properties.
function u2_CreateFcn(hObject, eventdata, handles)
% hObject handle to u2 (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'));
end
function u2_Callback(hObject, eventdata, handles)
% hObject handle to u2 (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 u2 as text
% str2double(get(hObject,'String')) returns contents of u2 as a double
% --- Executes during object creation, after setting all properties.
function L1_CreateFcn(hObject, eventdata, handles)
% hObject handle to L1 (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'));
end
function L1_Callback(hObject, eventdata, handles)
% hObject handle to L1 (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 L1 as text
% str2double(get(hObject,'String')) returns contents of L1 as a double
% --- Executes during object creation, after setting all properties.
function L2_CreateFcn(hObject, eventdata, handles)
% hObject handle to L2 (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'));
end
function L2_Callback(hObject, eventdata, handles)
% hObject handle to L2 (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 L2 as text
% str2double(get(hObject,'String')) returns contents of L2 as a double
% --- Executes during object creation, after setting all properties.
function alfa_CreateFcn(hObject, eventdata, handles)
% hObject handle to alfa (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'));
end
function alfa_Callback(hObject, eventdata, handles)
% hObject handle to alfa (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 alfa as text
% str2double(get(hObject,'String')) returns contents of alfa as a double
% --- Executes during object creation, after setting all properties.
function f1_CreateFcn(hObject, eventdata, handles)
% hObject handle to f1 (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'));
end
function f1_Callback(hObject, eventdata, handles)
% hObject handle to f1 (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 f1 as text
% str2double(get(hObject,'String')) returns contents of f1 as a double
% --- Executes during object creation, after setting all properties.
function f2_CreateFcn(hObject, eventdata, handles)
% hObject handle to f2 (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'));
end
function f2_Callback(hObject, eventdata, handles)
% hObject handle to f2 (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 f2 as text
% str2double(get(hObject,'String')) returns contents of f2 as a double
% --- Executes during object creation, after setting all properties.
function x_CreateFcn(hObject, eventdata, handles)
% hObject handle to x (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'));
end
function x_Callback(hObject, eventdata, handles)
% hObject handle to x (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 x as text
% str2double(get(hObject,'String')) returns contents of x as a double
% --- Executes during object creation, after setting all properties.
function xpr_CreateFcn(hObject, eventdata, handles)
% hObject handle to xpr (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'));
end
function xpr_Callback(hObject, eventdata, handles)
% hObject handle to xpr (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 xpr as text
% str2double(get(hObject,'String')) returns contents of xpr as a double
% --- Executes during object creation, after setting all properties.
function y_CreateFcn(hObject, eventdata, handles)
% hObject handle to y (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'));
end
function y_Callback(hObject, eventdata, handles)
% hObject handle to y (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 y as text
% str2double(get(hObject,'String')) returns contents of y as a double
% --- Executes during object creation, after setting all properties.
function ypr_CreateFcn(hObject, eventdata, handles)
% hObject handle to ypr (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'));
end
function ypr_Callback(hObject, eventdata, handles)
% hObject handle to ypr (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 ypr as text
% str2double(get(hObject,'String')) returns contents of ypr as a double
% --- Executes during object creation, after setting all properties.
function t0_CreateFcn(hObject, eventdata, handles)
% hObject handle to t0 (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'));
end
function t0_Callback(hObject, eventdata, handles)
% hObject handle to t0 (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 t0 as text
% str2double(get(hObject,'String')) returns contents of t0 as a double
% --- Executes during object creation, after setting all properties.
function tend_CreateFcn(hObject, eventdata, handles)
% hObject handle to tend (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'));
end
function tend_Callback(hObject, eventdata, handles)
% hObject handle to tend (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 tend as text
% str2double(get(hObject,'String')) returns contents of tend as a double
%--- Executes on button press in s1.
function s1_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s2;
set(off,'Value',0);
off = handles.s3;
set(off,'Value',0);
off = handles.s4;
set(off,'Value',0);
off = handles.s5;
set(off,'Value',0);
off = handles.s6;
set(off,'Value',0);
off = handles.s7;
set(off,'Value',0);
% --------------------------------------------------------------------
function s2_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s1;
set(off,'Value',0);
off = handles.s3;
set(off,'Value',0);
off = handles.s4;
set(off,'Value',0);
off = handles.s5;
set(off,'Value',0);
off = handles.s6;
set(off,'Value',0);
off = handles.s7;
set(off,'Value',0);
% --------------------------------------------------------------------
function s3_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s1;
set(off,'Value',0);
off = handles.s2;
set(off,'Value',0);
off = handles.s4;
set(off,'Value',0);
off = handles.s5;
set(off,'Value',0);
off = handles.s6;
set(off,'Value',0);
off = handles.s7;
set(off,'Value',0);
% --------------------------------------------------------------------
function s4_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s1;
set(off,'Value',0);
off = handles.s2;
set(off,'Value',0);
off = handles.s3;
set(off,'Value',0);
off = handles.s5;
set(off,'Value',0);
off = handles.s6;
set(off,'Value',0);
off = handles.s7;
set(off,'Value',0);
% --------------------------------------------------------------------
function s5_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s1;
set(off,'Value',0);
off = handles.s2;
set(off,'Value',0);
off = handles.s3;
set(off,'Value',0);
off = handles.s4;
set(off,'Value',0);
off = handles.s6;
set(off,'Value',0);
off = handles.s7;
set(off,'Value',0);
function s6_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s1;
set(off,'Value',0);
off = handles.s2;
set(off,'Value',0);
off = handles.s3;
set(off,'Value',0);
off = handles.s4;
set(off,'Value',0);
off = handles.s5;
set(off,'Value',0);
off = handles.s7;
set(off,'Value',0);
function s7_Callback(hObject, eventdata, handles)
set(hObject,'Value',1);
off = handles.s1;
set(off,'Value',0);
off = handles.s2;
set(off,'Value',0);
off = handles.s3;
set(off,'Value',0);
off = handles.s4;
set(off,'Value',0);
off = handles.s5;
set(off,'Value',0);
off = handles.s6;
set(off,'Value',0);
% --- Executes on button press in graphicsplot.
function graphicsplot_Callback(hObject, eventdata, handles)
% hObject handle to graphicsplot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
f1 = str2double(get(handles.f1,'String')); % f1
alfa = str2double(get(handles.alfa,'String')); % alfa
L2 = str2double(get(handles.L2,'String')); % L2
L1 = str2double(get(handles.L1,'String')); % L1
u2 = str2double(get(handles.u2,'String')); % u2
u1 = str2double(get(handles.u1,'String')); % u1
q = str2double(get(handles.q,'String'));
m = str2double(get(handles.m,'String')); % m
f2 = str2double(get(handles.f2,'String')); % f2
% read time intervall
t0 = str2double(get(handles.t0,'String')); % t_0
tend = str2double(get(handles.tend,'String')); % t_N
% read initial datas
y0(1) = str2double(get(handles.x,'String'));
y0(2) = str2double(get(handles.xpr,'String'));
y0(3) = str2double(get(handles.y,'String'));
y0(4) = str2double(get(handles.ypr,'String'));
y0 = [y0(1); y0(2); y0(3); y0(4)];
if (get(handles.s1, 'Value') == 1)
fun=@equation;
[tt,yy] = feval(ode45,fun,[t0 tend],y0,[],m,q,u1,u2,L1,L2,alfa,f1,f2)
end;
if (get(handles.s2, 'Value') == 1)
[tt,yy] = feval(ode23,@equation,[t0 tend],y0,[],m, q, u1, u2, L1, L2, alfa, f1, f2)
end;
if (get(handles.s3, 'Value') == 1)
[tt,yy] = feval(ode113,@equation,[t0 tend], y0,[], m, q, u1, u2, L1, L2, alfa, f1, f2);
end;
if (get(handles.s4, 'Value') == 1)
[tt,yy] = feval(ode15s,@equation,[t0 tend], y0,[], m, q, u1, u2, L1, L2, alfa, f1, f2);
end;
if (get(handles.s5, 'Value') == 1)
[tt,yy] = feval(ode23s,@equation,[t0 tend], y0,[], m, q, u1, u2, L1, L2, alfa, f1, f2);
end;
if (get(handles.s6, 'Value') == 1)
[tt,yy] = feval(ode23t,@equation,[t0 tend], y0,[], m, q, u1, u2, L1, L2, alfa, f1, f2);
end;
if (get(handles.s7, 'Value') == 1)
[tt,yy] = feval(ode23tb,@equation,[t0 tend],y0,[], m, q, u1, u2, L1, L2, alfa, f1, f2);
end;
n=length(tt);
% Visualization
figure(1)
maximize(gcf);
subplot(2,1,1),plot(tt(1:n),yy(1:n,1),'r'),grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('????? t'), ylabel('x')
title('????? ?? ???????? x = x(t)')
subplot(2,1,2),plot(tt(1:n),yy(1:n,3),'b'),grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('????? t'), ylabel('y')
title('????? ?? ???????? y = y(t)')
disp('????????? ?????????? ?????? ?? ???????????!'),pause
figure(2)
maximize(gcf);
subplot(2,1,1),plot(tt(1:n),yy(1:n,2),'r'),grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('????? t'), ylabel('x''')
title('??????? ?? ???????????? x''')
subplot(2,1,2),plot(tt(1:n),yy(1:n,4),'b'),grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('????? t'), ylabel('y''')
title('??????? ?? ???????????? y''')
disp('????????? ?????????? ?????? ?? ???????????!'),pause
figure(3)
maximize(gcf);
comet(yy(1:n,1),yy(1:n,2))
plot(yy(1:n,1),yy(1:n,2),'b'),grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('x'), ylabel('v')
title('?????? ?????????? v = v(x)')
disp('????????? ?????????? ?????? ?? ???????????!'),pause
figure(4)
maximize(gcf);
comet(yy(1:n,3),yy(1:n,4))
plot(yy(1:n,3),yy(1:n,4),'b'), grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('y'), ylabel('v')
title('?????? ?????????? v = v')
disp('????????? ?????????? ?????? ?? ???????????!'),pause
figure(5)
maximize(gcf);
colordef none
% ????????? ?? ??????? ?? ???? ?? ????????? ????????
hs = axes('units','normalized', ...
'position',[0 0 1 1]);
% ??????????? ?? ????????? ? ??????
uistack(hs,'bottom');
% ????????? ?? ????????????? ?? ???
I=imread('krak2.jpg');
hi = imagesc(I);
colormap gray
% ???????? ?? ????? ?? ????? ????????
set(hs ,'visible','off')
set(hi,'alphadata',.5)
axes('position',[0.40,0.25,0.4,0.4])
comet(yy(1:n,1),yy(1:n,3))
plot(yy(1:n,1),yy(1:n,3),'b'), grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('x'), ylabel('y')
title('?????????? ?? ???????? ?? ?????? ')
disp('????????? ?????????? ?????? ?? ???????????!'),pause
figure(6)
maximize(gcf);
colordef none
hs = axes('units','normalized', ...
'position',[0 0 1 1]);
uistack(hs,'bottom');
I=imread('krak2.jpg');
hi = imagesc(I);
colormap gray
set(hs ,'visible','off')
set(hi,'alphadata',.5)
axes('position',[0.40,0.25,0.4,0.4])
comet3(yy(1:n,1),yy(1:n,3),tt(1:n)),grid on
plot3(yy(1:n,1),yy(1:n,3),tt(1:n),'b'),grid on
set(gca,'FontName','Arial Cyr','FontSize',14)
xlabel('x'), ylabel('y'), zlabel('t')
title('?????????? ?? ???????? ?? ??????')
disp('????????? ?????????? ?????? ?? ???????????!'),pause
function f = equation(t,y, m, q, u1, u2, L1, L2, alfa, f1, f2)
% global m, q, u1, u2, L1, L2, alfa, f1, f2
% ?????????? ?? ????????????
% f=zeros(4,1);
f(1)=y(2);
f(2)=q/m*(u1/L1)*cos(2*pi*f1*t)+q/m*(u2/L2)*cos(alfa)*cos(2*pi*f2*t);
f(3)=y(4);
f(4)=q/m*(u2/L2)*sin(alfa)*cos(2*pi*f2*t);