Taking a derivative of a function and plotting it over a specified length

5 ビュー (過去 30 日間)
Aaron
Aaron 2013 年 2 月 19 日
Here is what I have so far. Keep getting errors. Trying to take the derivative of meanline and then plot this function over the length of x.
%Given variables
x = 0:0.1:2;
c = 2;
%Given Functions
meanline = c*(((x./c).^0.9)-(x./c));
thickness_distribution = ((2*c)/5)*(((x./c).^0.5)-(x./c));
%Solving
syms x
slope_meanline = diff(meanline);
%Plot
plot(x,slope_meanline)

回答 (2 件)

Jonathan Epperl
Jonathan Epperl 2013 年 2 月 19 日
Are you assigning the variable x before you call syms x? Probably, and that's probably the problem.
If you really want further help, you should post the error messages you are getting, "Keep getting errors" is not very helpful.
  1 件のコメント
Aaron
Aaron 2013 年 2 月 19 日
Tried putting the syms x before assigning the variable X and got this message.
??? Error using ==> plot
Vectors must be the same lengths.
Error in ==> wind_hw5 at 20
plot(x,slope_meanline)

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


Youssef  Khmou
Youssef Khmou 2013 年 2 月 19 日
編集済み: Youssef Khmou 2013 年 2 月 19 日
hi Aaron
you get error because because slope_meanline is numeric and you want to plot numeric vs symbolic , there are many ways to solve the problem, try this :
c=2;
syms x;
meanline = c*(((x./c).^0.9)-(x./c));
slope_meanline=diff(meanline);
range=[0 10];
ezplot(slope_meanline,range )
Adjust the range to your need .

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by