why the error is written here (Not enough input arguments.)

function dydt= project(t,psi)
M=5; m=0.5; R=0.5; tau=10*sin(100*t); F=10*cos(10*t) ; ddx=2;
dydt(1)=y(3);
dydt(2)=y(4);
dydt(3)=-(M*R^2*y(3) - 2*tau + 2*R^2*y(3)*m + 2*R*ddx*sin(y(1)))/(2*R*cos(y(1)))
dydt(4)=(M^2*R^2*y(3) + 3*M*R^2*y(3)*m + 2*ddx*sin(y(1))*M*R - 2*tau*M + 2*cos(y(1))*sin(y(1))*R^2*y(3)^2 + 2*R^2*y(3)*m^2 + 2*ddx*sin(y(1))*R*m + 2*F*cos(y(1))*R - 2*tau*m)/(2*R^2*cos(y(1))^2)
dydt=dydt';
end

 採用された回答

madhan ravi
madhan ravi 2018 年 12 月 16 日
編集済み: madhan ravi 2018 年 12 月 16 日

1 投票

[t,y]=ode45(@project,[0 10],[0;0;0;0]) ; % you forgot to call the function with input arguments
plot(t,y(:,1))
figure
plot(t,y(:,2),'r')
figure
plot(t,y(:,3),'g')
figure
plot(t,y(:,4),'m')
function dydt= project(t,y) % function definition
M=5; m=0.5; R=0.5; tau=10*sin(100*t); F=10*cos(10*t) ; ddx=2;
dydt=zeros(4,1);
dydt(1)=y(3);
dydt(2)=y(4);
dydt(3)=-(M*R^2*y(3) - 2*tau + 2*R^2*y(3)*m + 2*R*ddx*sin(y(1)))/(2*R*cos(y(1)));
dydt(4)=(M^2*R^2*y(3) + 3*M*R^2*y(3)*m + 2*ddx*sin(y(1))*M*R - 2*tau*M + 2*cos(y(1))*sin(y(1))*R^2*y(3)^2 + 2*R^2*y(3)*m^2 + 2*ddx*sin(y(1))*R*m + 2*F*cos(y(1))*R - 2*tau*m)/(2*R^2*cos(y(1))^2);
end
Screen Shot 2018-12-16 at 4.54.22 PM.png
Screen Shot 2018-12-16 at 4.54.31 PM.png
Screen Shot 2018-12-16 at 4.54.37 PM.png
Screen Shot 2018-12-16 at 4.54.43 PM.png

9 件のコメント

Mustafa Alhandhali
Mustafa Alhandhali 2018 年 12 月 16 日
it is written
Function definitions are not permitted in this context.
madhan ravi
madhan ravi 2018 年 12 月 16 日
save the function as project.m and then just try my answer with the first 8 lines without function definition.
Mustafa Alhandhali
Mustafa Alhandhali 2018 年 12 月 16 日
when i try to save the function it witten "Not enough input arguments."
madhan ravi
madhan ravi 2018 年 12 月 16 日
編集済み: madhan ravi 2018 年 12 月 16 日
man you are not obviously saving you are trying to run the function by clicking the green button..
Mustafa Alhandhali
Mustafa Alhandhali 2018 年 12 月 16 日
how i can find relation (psi with time)
and y with time
madhan ravi
madhan ravi 2018 年 12 月 16 日
編集済み: madhan ravi 2018 年 12 月 16 日
Since I don't have your equation in latex form you can easily find the relationship dydt represents the equations likewise for the rest and every equation are plotted against time.
Mustafa Alhandhali
Mustafa Alhandhali 2018 年 12 月 16 日
ok thank you so much
madhan ravi
madhan ravi 2018 年 12 月 16 日
Anytime :)
Mustafa Alhandhali
Mustafa Alhandhali 2018 年 12 月 16 日
last quastion :(
if i want to replace the function of F( F=10*cos(10*t))
to pulse functin first and in another exmple to unit step funnction
how i can write the code
note: i want any exapmles of pulse functin and unit step funnction which can i write it here

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeApp Building についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by