Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

The result can't shown as a graph in Gui Matlab

1 vue (au cours des 30 derniers jours)
Kesni savitri
Kesni savitri le 15 Mai 2013
Clôturé : MATLAB Answer Bot le 20 Août 2021
I have a trouble to get plot of my task. there is contain of 3 differential equation. i used GUI 'edit' to manage parameter a,and b
function model_openingFcn(hObject,eventdata,handles,umpan)
global a1; global a2; global b1; global b2;
a1=2;a2=4;b1=3;b2=5;
handles.typeFlag=1
set(handles.a_variations,'Value',1);
set(handles.b_2,'enable','off');
set(handles.a_1,'String',num2str(a1));
set(handles.a_2,'String',num2str(a2));
set(handles.b_1,'String',num2str(a1));
guidata(hObject,handles)
%the diff eq to parameter a1
function dydt=myfunc1(t,yp,a1,b1)
dydt=zeros(3,1)
dydt(1)=3*yp(1)*a1+yp(4)*b1;
dydt(2)=2*yp(3)*b1;
dydt(3)=yp(4)*a1;
%the diff eq to parameter a1
function dydt=myfunc2(t,yq,a2,b1)
dydt=zeros(3,1)
dydt(1)=3*yq(1)*a2+yq(4)*b1;
dydt(2)=2*yq(3)*b1;
dydt(3)=yq(4)*a2;
%the diff eq to parameter a1
function dydt=myfunc3(t,yr,a1,b2)
dydt=zeros(3,1)
dydt(1)=3*yr(1)*a1+y(4)*b2;
dydt(2)=2*yr(3)*b2;
dydt(3)=yr(4)*a1;
%function callback for pushbutton
guidata(hObject,handles);
if handles.Flag=1
set(handles.a_variations,'Value',1);
set(handles.b_2,'enable','off');
set(handles.a_1,'String',num2str(a1));
set(handles.a_2,'String',num2str(a2));
set(handles.b_1,'String',num2str(b1));
else hanldes.Flag=2
set(handles.b_variations,'Value',1);
set(handles.a_2,'enable','off');
set(handles.a_1,'String',num2str(a1));
set(handles.b_2,'String',num2str(b2));
set(handles.b_1,'String',num2str(b1));
end
dynamicmodel(handles);
%>>>>>>>>>>>> make function to dynamicmodel(handles)
function dynamicmodel(handles);
switch handles.typeFlag
case 1
opts=odeset('Refine',10);
[t,yp]=ode45(@myfunc1,[0 10],[1 3 4 5], opts,a1,b1);
[t,yq]=ode45(@myfunc2,[0 10],[1 3 4 5], opts,a2,b1);
plot(handles.axes1,t,yp(:,1),'b',t,yq(:,1),'m');
title('effect variation parameter a to y1')
xlabel('t')
ylabel('y')
case 2
opts=odeset('Refine',10);
[t,yp]=ode45(@myfunc1,[0 10],[1 3 4 5], opts,a1,b1);
[t,yq]=ode45(@myfunc3,[0 10],[1 3 4 5], opts,a1,b2);
plot(handles.axes1,t,yp(:,1),'b',t,yq(:,1),'m');
title('effect variation parameter b to y1')
xlabel('t')
ylabel('y')
error result showed the graphic, in command window ??? Error using ==> plot Vectors must be the same lengths.
Error in ==> model>dynamicmodel
plot(handles.axes1,t,yp(:,1),'b',t,yq(:,1),'m');
Error in ==> model>btn_calculate_Callback at 158
modeldinamika(handles);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> model at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)model('btn_calculate_Callback ',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
So what can i do to solve this error?

Réponses (1)

Image Analyst
Image Analyst le 15 Mai 2013
Put these lines just before the call to plot():
whos t
whos yp
whos yq
Evidently either yp or yq is not the same length as t.

Cette question est clôturée.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by