How to plot a derivative against variable?
古いコメントを表示
Use if statements to select an equation for x based on the inputed value for damping. Plot a graph of x (displacement) against time (this bit works). Then want to differentiate x for velocity, and differentiate velocity for acceleration and then plot all three. I used:
syms t
v = diff(x,1)
plot(t,v)
Get error "Data must be numeric, datetime, duration, categorical, or an array convertible to double."
x is a previously selected equation with t as a variable, also includes Z but this is asked for and inputted at the beginning.
2 件のコメント
John D'Errico
2023 年 4 月 1 日
What do you expect? Read what you did. You did this:
syms t
v = diff(x,1)
What is x? Should MATLAB know that x is something possibly related to t? Why should it? Possibly x is a variable that already exists, since if it did not exist, you would have gotten a different error.
You claim that x already exists, but we don't see what it is. Is x an "equation", perhaps a function? Is it just a variable of some ilk? Is x something symbolic?
You are not telling us enough information to know what you did, except that you did something that caused an error.
River
2023 年 4 月 1 日
編集済み: Walter Roberson
2023 年 4 月 1 日
採用された回答
その他の回答 (1 件)
Peter Perkins
2023 年 4 月 5 日
0 投票
For extra credit, create a timetable from displacement, add velocity and accel, then use stackedplot to plot all three together.
カテゴリ
ヘルプ センター および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!