Physics Quıestion in Matlab

1 回表示 (過去 30 日間)
Aykut Albayrak
Aykut Albayrak 2018 年 1 月 21 日
コメント済み: Birdman 2018 年 1 月 21 日
As you can see question in below.I wrote this code but matlab gives some error.What can I do?
if true
function [outputArg1,outputArg2] = untitled2(inputArg1,inputArg2)
F=3;
x=1;
k=-F/x;
k
x(0)=1;
Dx(0)=-0.5;
x(t)=c1*sin(sqrt(k/m)*t)+c2*cos(sqrt(k/m));
end

採用された回答

Birdman
Birdman 2018 年 1 月 21 日
編集済み: Birdman 2018 年 1 月 21 日
Learn how to use Symbolic Toolbox first. Here is one approach:
F=3;m=4;x0=1;
%%1st
k=F/x0;
%%2nd-3rd
syms x(t)
eq=m*diff(x,t,2)==-k*x;
Dx=diff(x,t);
x=dsolve(eq,[x(0)==1 Dx(0)==0.5])
%4th
t=subs(t,0:0.01:2);
x=subs(x,t);
plot(t,x)
  2 件のコメント
Aykut Albayrak
Aykut Albayrak 2018 年 1 月 21 日
Thank you so much.You are the best matlab coder!
Birdman
Birdman 2018 年 1 月 21 日
Ah, no. Just someone with little experience about this stuff. You are welcome :)

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

その他の回答 (1 件)

Roger Stafford
Roger Stafford 2018 年 1 月 21 日
編集済み: Roger Stafford 2018 年 1 月 21 日
Matlab does not accept indices equal to zero. These can only be positive integers greater than zero. Therefore "x(0)=1;" and "Dx(0)=-0.5;" are not permitted. The same would apply to "x(t)" if 't' were of improper size.
  1 件のコメント
Aykut Albayrak
Aykut Albayrak 2018 年 1 月 21 日
So,What can I write?

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

カテゴリ

Help Center および File ExchangeCode Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by