Plotting differential equations, need help
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
y = diff(sin(2*pi*t))./diff(t);
plot(t,y)
Remember diff() shortens the length of your vector by one so you will need to define a new time vector to plot against. ---- how do i do this?
thank you
採用された回答
Yu Jiang
2014 年 10 月 6 日
plot(t(2:end),y)
8 件のコメント
Andrew
2014 年 10 月 6 日
yeah works for sin(), however when you try to do it for t^2. come sup with error.
Geoff Hayes
2014 年 10 月 6 日
What is the error, and the line(s) of code that you are using?
Andrew
2014 年 10 月 6 日
using your fix for the plot(t(2:end),y), as plot(t,y) doesn't work
Error using diff
Difference order N must be a positive integer scalar.
Andrew
2014 年 10 月 6 日
y=diff(t,t);
plot(y,t)
returning an error
what is the t vector? What is the expected result from y=diff(t,t)?? This is different from you original post.
I tried the following on my machine, and it worked
t = linspace(-10,10,100);
y = diff(sin(2*pi*t))./diff(t);
plot(t(2:end),y)
Andrew
2014 年 10 月 6 日
yeah it works, but when u integrate that technique into a different equation, it triggers an error.
Andrew
2014 年 10 月 6 日
its ok, i fixed it. thanks for your help sir.
Yu Jiang
2014 年 10 月 6 日
You are welcome.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Numerical Integration and Differential Equations についてさらに検索
参考
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
